[launchd-dev] Programmatic interface to launchctl and some other questions, OS X 10.5

Quinn "The Eskimo!" eskimo1 at apple.com
Tue Oct 26 05:06:34 PDT 2010


On 26 Oct 2010, at 12:52, eveningnick eveningnick wrote:

> Could you tell a little more about what kind of services do you
> provide usually and how do you respond to them? Is it something like
> AppleEvents? Or some kind of user-signals?

For a launchd daemon, I usual communicate with the daemon via a UNIX domain socket.  So, in the client application, I just create a UNIX domain socket and try to connect it to the daemon's socket path.  If that succeeds, I know that the daemon is running.

For an agent, you can do similar things but you have to use the "SecureSocketWithKey" property to ensure that each agent has its own unique socket path (although there are some wacky edge cases for the first install case).  See <x-man-page://5/launchd.plist> for details.

Alternatively, you can register a Mach port using the "MachServices" property.  This works nicely for both the daemon and the agent case, but Mach IPC is kinda ugly in my experience.

                   *                   *                   *

It would really help if you could explain your high-level goal in high-level terms.  Right now I think we're getting bogged down in the details, without a clear understanding of the overall problem.  Specifically:

o Are you trying to install your agent for a specific user, or for all users?

o Once installed, how does your agent get uninstalled?

o If you are trying to install your agent for all users, do you care about the fast user switched case?  That is, when there are multiple users logged in via fast user switching, do you care whether users other than the one installing your software get the agent straight away?

o What are you trying to do with daemons?

o Do your agents (and daemons for that matter) have any command and control interface?  If so, what are you planning to use for that?

S+E
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware




More information about the launchd-dev mailing list