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

James Bucanek subscriber at gloaming.com
Sun Mar 16 10:16:19 PDT 2008


Mac QA <mailto:macqaguy at gmail.com> wrote (Tuesday, March 11, 
2008 1:41 PM -0400):

>The mylaunchagent is invoked just fine. If I do a fast user switch to
>login another user then a second instance is invoked for the second
>user. All seems good. However, when the second user logs out the
>second instance of mylaunchagent continues to stay running even though
>the user logs out!

There are several levels of "logged in/out".

A launchd Aqua session is created when the user logs into the 
GUI. When the user logs out again, the Aqua session ends. 
Restrict your user agent to the Aqua session and it should 
behave the way you are expecting.

     <key>LimitLoadToSessionType</key>
     <string>Aqua</string>

In contrast, the Background session for a user gets created 
whenever a process for that user is created. This also gets 
created when the user logs into the GUI but can just as easily 
be created by starting a remote terminal session via ssh. The 
Background session does not end when the user logs out of the GUI.

My product actually uses this fact to provide services for users 
after they log out.

-- 
James Bucanek



More information about the launchd-dev mailing list