I have a Qt app that uses the c xpc api to talk to an elevated launchd service that the app installs with SMJobBless. This all works fine. I'd like add the behavior that the next time the user launches the app it just starts communicating with the the service. The problem I'm actually trying to solve is determining if the service is already installed. I tried making a connection and sending a message, my thought was I'll get an invalid connection and if so, install the server and then try again. If I try this sequence I can't get the connection to function.
I've tried a few things to get this to work; canceling the first connection, releasing the first connection and making another, ignoring the first connection and creating another all to no avail. What does xpc need me to do to get it back into a state where it will connect after a fail with an invalid connection because the service doesn't exist yet?
Or is there a different way to determine it isn't there in the first place? Should I go spelunking the file system and look in /Library/PrivilegedHelperTools for my service executable and /Library/LaunchDaemons/ for the plist?
Cheers,
- James
PS I determined empirically that the error event block is executed in a thread created by the os but the reply block appears to alwats execute in the thread I send the message from. Did I miss the part in the docs where this is described?