EvenBetterAuthorizationSample and launchd or XPC transactions

I'm updating a launchd priviledged helper tool and switching it from using a UNIX domain socket for IPC to using the more modern NSXPCConnection API as per the EvenBetterAuthorizationSample code. Now the ReadMe for the EvenBetterAuthorizationSample states that it is not currently posible for a XPC-based launchd daemon to safely adopt launchd transactions or take advantage of XPC transactions, but the "ProcessType" (10.9 or higher) and "EnablePressureExit" (10.10 or higher) launchd.plist keys seem to indicate that the ReadMe might now be a bit out of date.

Is it possible to use the "ProcessType", "EnableTransactions" and "EnablePressureExit" launchd keys with a XPC-based launchd daemon on 10.9 or higher to take advantage of XPC transactions?

Is it recommended to use those keys?

Finally the man page for xpc_transaction_begin() defines the duration of a XPC transaction based upon when a reply is created with xpc_dictionary_create_reply() but that is an implemetation detail hidden by the higher level NSXPCConnection API. Will a XPC transaction be "held" until the the reply block is called for any exported NSXPCConnection interface method that requires a reply?

Accepted Reply

EvenBetterAuthorizationSample states that it is not currently posible for a XPC-based launchd daemon to safely adopt launchd transactions or take advantage of XPC transactions, but [the launchd docs] seem to indicate that the ReadMe might now be a bit out of date.

Indeed.

Is it recommended to use those keys?

In general we recommend that you support pressure exit because it give good performance by default and good memory behaviour on memory-constrained systems.

Will a XPC transaction be "held" until the the reply block is called for any exported NSXPCConnection interface method that requires a reply?

Yes. For standard request/reply IPCs, NSXPCConnection takes care of the transaction support for you much like the C API.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Replies

EvenBetterAuthorizationSample states that it is not currently posible for a XPC-based launchd daemon to safely adopt launchd transactions or take advantage of XPC transactions, but [the launchd docs] seem to indicate that the ReadMe might now be a bit out of date.

Indeed.

Is it recommended to use those keys?

In general we recommend that you support pressure exit because it give good performance by default and good memory behaviour on memory-constrained systems.

Will a XPC transaction be "held" until the the reply block is called for any exported NSXPCConnection interface method that requires a reply?

Yes. For standard request/reply IPCs, NSXPCConnection takes care of the transaction support for you much like the C API.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"