Help with launchd sockets chicken and egg problem
Hey all... I have my master process. It wants to spawn a child process that will startup automatically on reboot. I would like these processes to be able to communicate via sockets, but I don't want to hardcode a port, I would like to use "SecureSocketWithKey" and let launchd take care of starting my process on demand (and clean up the file system as appropriate). Master process puts together a plist and installs it into LaunchAgents. It then calls launchctl and has it load it. The child process calls checks in and is able to get it's socket. How does the master process get the socket on it's end? I understand that if I reboot the system that I can get the socket path via an environment variable, but how do I get it without rebooting? Any info would be greatly appreciated. Cheers, Dave
On 1 Nov 2010, at 23:24, Dave MacLachlan wrote:
I understand that if I reboot the system that I can get the socket path via an environment variable, but how do I get it without rebooting?
Yeah, this is a bit of a bear. launchd has a serious conceptual gap when it comes to the install, upgrade, and uninstall process. We're tracking this as <rdar://problem/5476420>. By far the best solution from a technical perspective is to force a restart of the system. Obviously this is less than ideal from a UE perspective. As to workarounds, I haven't ever investigated this properly, but I think the easiest would be for your master process to just quit and have launchd relaunch it, at which point it will profit the environment variable you specified via SecureSocketWithKey. S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
participants (2)
-
Dave MacLachlan
-
Quinn "The Eskimo!"