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

Hamish Allan hamish at gmail.com
Tue Mar 11 13:55:08 PDT 2008


On Tue, Mar 11, 2008 at 8:41 PM, Mac QA <macqaguy at gmail.com> wrote:

>  The Apple Multiple User Environments document [1] makes two statements
>  regarding this. First, "If a user process daemonizes itself prior to
>  logout, it can live past the end of the user logout and prolong the
>  existence of the login session." And Second, "Per-user services are
>  shut down automatically and are not given the chance to abort the
>  logout procedure." The mylaunchagent process is always a background
>  process just invoked by launchd, so given the first statement I guess
>  that is why it is persisting logout. However, given the second
>  statement, since this is a per-user service as launchagents are by
>  definition, I don't understand why it isn't shut down automatically on
>  logout. Frankly, those two statements seem contradictory.

I take the second statement to mean "We send a SIGKILL to the agent".
If the agent has daemonized, the child will have been re-parented,
hence the first statement.

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


More information about the launchd-dev mailing list