At 18:44 +0530 8/6/09, Arjun SM wrote:
I am getting this message when i am trying to launch my application which is a LaunchAgent. This message comes only when multiple Users are logged in.
Yeah, your script, as its written, is never going to work. The problem is that, except when run as root, launchctl finds the right launchd to talk to by looking it up in the Mach bootstrap namespace. Your script is always running in one user's namespace, so will always end up talk to that user's launchd (which ends badly because of permissions). The launchd story is a quite weak when it comes to installing and upgrading agents where there are users logged in. This is a well known problem <rdar://problem/5476420> but, alas, I don't have any good news to share with you on this front. This problem breaks down as follows: o upgrade -- There /is/ a reasonable way to handle the upgrade scenario. Most agents are running on behalf of a daemon. In that case you can overwrite the agent on disk and then tell the daemon to signal all of the agents to quit. They will be relaunched by their respective launchd's, this time running the new code. You have to be a little careful, but this approach works reasonably well. o first install -- There isn't a good way to handle the first install case. You can start the agent in the GUI context that you're running in, but starting agents in other existing GUI contexts is tricky. In general I'd recommend you /not/ try to solve this. Non-foreground GUI users will have to log out and log back in to pick up your agent. If that's a problem (for example, you're installing security software), force a restart in that case. Keep in mind that the multiple GUI logins via fast user switching is an edge case that 90% of your users will never encounter. S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware