[launchd-dev] Possible to work around 10.4 LaunchAgent bugs?

Quinn eskimo1 at apple.com
Wed Aug 12 01:42:22 PDT 2009


At 13:38 -0400 11/8/09, Sidney San Martín wrote:
>To: "launchd-dev at lists.macosforge.org" <launchd-dev at lists.macosforge.org>,
>  "cocoa-dev at lists.apple.com" <cocoa-dev at lists.apple.com>

Please don't cross post like this.  It causes all 
sorts of issues.  For example, I'm not subscribed 
to cocoa-dev, so I can post to that list so they 
can see my responses, and I can't see if anyone 
else has already responded.  You're better off 
posting to one list, waiting a few days for 
answers, and then posting to the second list.

At 13:38 -0400 11/8/09, Sidney San Martín wrote:
>Has anyone found workarounds for the issues in 
>10.4? Can I program my agent to handle the error 
>conditions that lead to a failed launch (detect 
>non-gui sessions, for instance) and exit 
>gracefully before launchd rips it out?

There are no good workarounds to this problem. 
Your agent is always run by a per-user launchd. 
The context in which that launchd runs depends on 
the context that first invoked a per-user launchd 
feature, which obviously means that it's not 
something that you can rely on.  Detecting this 
problem won't help; it's relatively easy to 
detect it, but you can't do anything to fix it.

The other gotcha is that the per-user launchd 
won't quit when the GUI session logs out.  At 
that point any agent it runs will be in a GUI 
session, but just not the /right/ GUI session, 
and all sorts of grief ensues.  Again, you could 
probably detect this, but there's no easy way to 
fix it.

This is all very ugly, to the point where it 
makes the global login item workaround look nice.

Of course the simple solution to this problem is 
to drop support for 10.4.x.  With the impending 
release of Snow Leopard, general support for 
10.4.x is going to start fading away.

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