Possible to work around 10.4 LaunchAgent bugs?
My current project needs an agent to run whenever a user is logged in. A LaunchAgent would be perfect for this, and in 10.5, it is. If I can't use a LaunchAgent on 10.4, the alternative isn't so appealing: * I'd need to use barely-supported procedures to install a global login item. * There would be separate install, update, and uninstall code paths for 10.4, 10.5+, and a 10.4 to 10.5+ migration * The daemon would need to be able to detect a migration from 10.4 to 10.5+ and convert the global login item to a LaunchAgent on first boot That's a little more complexity (and potential for a failure) than I want. 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?
At 13:38 -0400 11/8/09, Sidney San Martín wrote:
To: "launchd-dev@lists.macosforge.org" <launchd-dev@lists.macosforge.org>, "cocoa-dev@lists.apple.com" <cocoa-dev@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
participants (2)
-
Quinn
-
Sidney San Martín