@@ -13,6 +13,7 @@ const xpc_dictionary_get_int64 = new NativeFunction(libxpc.findExportByName('xpc
13
13
14
14
const xpc_array_create_empty = new NativeFunction ( libxpc . findExportByName ( 'xpc_array_create_empty' ) , 'pointer' , [ ] ) ;
15
15
const xpc_array_append_value = new NativeFunction ( libxpc . findExportByName ( 'xpc_array_append_value' ) , 'void' , [ 'pointer' , 'pointer' ] ) ;
16
+ const xpc_array_get_int64 = new NativeFunction ( libxpc . findExportByName ( 'xpc_array_get_int64' ) , 'int64' , [ 'pointer' , 'size_t' ] ) ;
16
17
17
18
const xpc_string_create = new NativeFunction ( libxpc . findExportByName ( 'xpc_string_create' ) , 'pointer' , [ 'pointer' ] ) ;
18
19
const xpc_uuid_create = new NativeFunction ( libxpc . findExportByName ( 'xpc_uuid_create' ) , 'pointer' , [ 'pointer' ] ) ;
@@ -112,11 +113,14 @@ rpc.exports.run = function (pluginIdentifier) {
112
113
return reject ( new Error ( `unexpected error returned from pkd ${ xpcDescription ( reply ) } ` ) ) ;
113
114
114
115
const pids = xpc_dictionary_get_value ( reply , Memory . allocUtf8String ( 'pids' ) ) ;
115
- if ( pids . isNull ( ) )
116
- return reject ( new Error ( 'pids is null' ) ) ;
117
-
118
- const pid = xpc_dictionary_get_int64 ( pids , Memory . allocUtf8String ( pluginUUIDString ) ) ;
119
- resolve ( pid . toNumber ( ) ) ;
116
+ if ( ! pids . isNull ( ) )
117
+ return resolve ( xpc_dictionary_get_int64 ( pids , Memory . allocUtf8String ( pluginUUIDString ) ) . toNumber ( ) ) ;
118
+
119
+ const pidarray = xpc_dictionary_get_value ( reply , Memory . allocUtf8String ( 'pidarray' ) ) ;
120
+ if ( ! pidarray . isNull ( ) )
121
+ return resolve ( xpc_array_get_int64 ( pidarray , 0 ) . toNumber ( ) ) ;
122
+
123
+ reject ( new Error ( `unknown schema for XPC reply: ${ xpcDescription ( reply ) } ` ) ) ;
120
124
}
121
125
} ) ) ;
122
126
} ) ;
0 commit comments