[launchd-dev] Agent started two different was, two different bootstraps?

James Bucanek subscriber at gloaming.com
Fri Jan 25 10:38:26 PST 2008

Hello again,

I've got a persistent oddity. I have a drag-install application 
that automatically installs a couple of launch agents with 
configuration plists (in ~/Library/LaunchAgents/). The processes 
and my GUI Cocoa application all communicate using distributed 
objects via Mach ports.

When the agents get installed the first time, I kick-start them 
using 'launchctl load ...'. The problem is this: The two launch 
agents are installed and started using launchctl load (running 
launchctl as the regular user). The Cocoa application then 
starts a helper process (using NSTask) which registers a named 
Mach port.

Now at this point, I would think that all four processes should 
be running in the Auqa bootstrap (the Cocoa application, the 
agent, and the helper process). But the agent can't see/connect 
with the Mach port registered by the helper process. The 
application can see it, connect to it, and does its thing. But 
when one of the agents attempts to connect with the same helper 
process, they get an error.

Here's the oddity: If I restart the computer things appear to 
work correctly. When they agents are started automatically as 
part of the user's login procedure, they all communicate with 
each other just fine.

Am I loading the agents incorrectly?

Is this a known problem, or do I have to try to develop a 
reproducible case and file a bug report?

More information about the launchd-dev mailing list