[launchd-dev] My Launch Agent is Persisting Beyond Logout

Mac QA macqaguy at gmail.com
Thu Mar 13 12:57:01 PDT 2008


On Tue, Mar 11, 2008 at 4:55 PM, Hamish Allan <hamish at gmail.com> wrote:
>  In short: the mylaunchagent process must not daemonize, i.e., must not
>  fork and exit. If it has a '-f' (run in foreground) option or similar,
>  use that.

Hamish,

Thanks for the clarification. I think I understand the situation now.
The mylaunchagent process is a Cocoa tool that I wrote myself, and I
have no call to fork or exit in it. Yet it is meant to be a background
process invoked with launchd, so I guess that is the same thing.


On Tue, Mar 11, 2008 at 11:11 PM, Dave Zarzycki <zarzycki at apple.com> wrote:
>  Does your agent catch Unix signals? Can you please do a "launchctl
>  list com.company.mylaunchagent" and email us the results?

Dave,

No I don't catch Unix signals, my launch agent is written in Cocoa.
I've never been aquatinted with unix signals before. Shouldn't there
be a Cocoa notification to tell my lunch agent daemon that the user is
logging out to allowing me to clean-up and terminate the program? All
I can find is NSWorkspaceSessionDidResignActiveNotification, but this
is for if a fast user switch is performed not an actual logout.

In response to your inquiry about launchctl it only prints the name I
put in. So, I logged in 3 users via fast user switch, logded out two
of them, then Activity Monitor shows 3 instances of my launch agent
still running. And launchctl shows:

$ launchctl list com.company.mylaunchagentd
com.company.mylaunchagentd


Thank you both for your responses.


More information about the launchd-dev mailing list