Launch Agent and per-user launchd not exiting on logout (10.5.8)
I ran into a machine running OS 10.5.8 recently where our launchd agent and the user's launchd did not terminate at logout. On the next login, an "Already loaded" message was logged for our plist, followed by a number of errors from the agent itself. A snippet of the log is below. After killing and relaunching the agent it was fine for that session. After rebooting the machine, I was unable to reproduce the problem. I remember happening in 10.4, but never in 10.5... Are there any circumstances that'd cause launchd to misbehave like this? Is there anything I should be doing to handle the situation more gracefully in my agent? 6/18/10 4:15:41 PM com.apple.launchctl.Aqua[957] com.mycompany.agent: Already loaded 6/18/10 3:54:47 PM MyCompany Agent[616] _NXPlaceWindow: error setting window shape (268435459) 6/18/10 3:54:47 PM MyCompany Agent[616] _NSShapePlainWindow: error setting window shape (268435459) 6/18/10 3:54:47 PM MyCompany Agent[616] _NSShapePlainWindow: error setting window shape (268435459) 6/18/10 3:54:47 PM MyCompany Agent[616] CGSLookupServerPort: _CGSSessionDeathWatchPort(gSessionPort) returns 268435459 6/18/10 3:54:47 PM com.mycompany.agent[616] Fri Jun 18 15:54:47 Terminal-1.local MyCompany Agent[616] <Warning>: CGSLookupServerPort: _CGSSessionDeathWatchPort(gSessionPort) returns 268435459 6/18/10 3:54:47 PM MyCompany Agent[616] CGSShutdownServerConnections: Detaching application from window server 6/18/10 3:54:47 PM com.mycompany.agent[616] Fri Jun 18 15:54:47 Terminal-1.local MyCompany Agent[616] <Warning>: CGSShutdownServerConnections: Detaching application from window server 6/18/10 3:54:47 PM MyCompany Agent[616] CGSDisplayServerShutdown: Detaching display subsystem from window server 6/18/10 3:54:47 PM com.mycompany.agent[616] Fri Jun 18 15:54:47 Terminal-1.local MyCompany Agent[616] <Warning>: CGSDisplayServerShutdown: Detaching display subsystem from window server 6/18/10 3:54:59 PM MyCompany Agent[616] kCGErrorCannotComplete : CGSDeviceGetGeometry: Invalid device window 6/18/10 3:54:59 PM MyCompany Agent[616] kCGErrorCannotComplete : CGSDeviceGetGeometry: Invalid device window 6/18/10 3:54:59 PM MyCompany Agent[616] kCGErrorInvalidConnection : CGSGetWindowGeometry: Invalid connection 6/18/10 3:54:59 PM MyCompany Agent[616] kCGErrorInvalidConnection : CGSGetWindowGeometry: Invalid connection 6/18/10 3:54:59 PM MyCompany Agent[616] kCGErrorInvalidConnection : CGSGetWindowGeometry: Invalid connection 6/18/10 3:54:59 PM MyCompany Agent[616] kCGErrorInvalidConnection : CGSGetWindowGeometry: Invalid connection 6/18/10 3:54:59 PM MyCompany Agent[616] kCGErrorCannotComplete : CGSDeviceGetGeometry: Invalid device window 6/18/10 3:54:59 PM com.mycompany.agent[616] Fri Jun 18 15:54:59 Terminal-1.local MyCompany Agent[616] <Error>: kCGErrorCannotComplete : CGSDeviceGetGeometry: Invalid device window 6/18/10 3:54:59 PM com.mycompany.agent[616] Fri Jun 18 15:54:59 Terminal-1.local MyCompany Agent[616] <Error>: kCGErrorCannotComplete : CGSDeviceGetGeometry: Invalid device window 6/18/10 3:54:59 PM com.mycompany.agent[616] Fri Jun 18 15:54:59 Terminal-1.local MyCompany Agent[616] <Error>: kCGErrorInvalidConnection : CGSGetWindowGeometry: Invalid connection 6/18/10 3:54:59 PM com.mycompany.agent[616] Fri Jun 18 15:54:59 Terminal-1.local MyCompany Agent[616] <Error>: kCGErrorInvalidConnection : CGSGetWindowGeometry: Invalid connection 6/18/10 3:54:59 PM com.mycompany.agent[616] Fri Jun 18 15:54:59 Terminal-1.local MyCompany Agent[616] <Error>: kCGErrorInvalidConnection : CGSGetWindowGeometry: Invalid connection 6/18/10 3:54:59 PM com.mycompany.agent[616] Fri Jun 18 15:54:59 Terminal-1.local MyCompany Agent[616] <Error>: kCGErrorInvalidConnection : CGSGetWindowGeometry: Invalid connection 6/18/10 3:54:59 PM com.mycompany.agent[616] Fri Jun 18 15:54:59 Terminal-1.local MyCompany Agent[616] <Error>: kCGErrorCannotComplete : CGSDeviceGetGeometry: Invalid device window 6/18/10 3:54:59 PM com.mycompany.agent[616] Fri Jun 18 15:54:59 Terminal-1.local MyCompany Agent[616] <Error>: kCGErrorCannotComplete : CGSDeviceSynchronize: Invalid device window 6/18/10 3:54:59 PM MyCompany Agent[616] kCGErrorCannotComplete : CGSDeviceSynchronize: Invalid device window 6/18/10 4:13:52 PM /Library/Application Support/MyCompany/MyCompany Agent.app/Contents/MacOS/MyCompany Agent[861] SessionGetInfo(0xb33e40) -> -2147417855 6/18/10 4:13:52 PM /Library/Application Support/MyCompany/MyCompany Agent.app/Contents/MacOS/MyCompany Agent[861] SessionGetInfo(0xb33e40) -> -2147417855 6/18/10 4:14:32 PM /Library/Application Support/MyCompany/MyCompany Agent.app/Contents/MacOS/MyCompany Agent[865] SessionGetInfo(0xb33e40) -> -2147417855 6/18/10 4:14:32 PM /Library/Application Support/MyCompany/MyCompany Agent.app/Contents/MacOS/MyCompany Agent[865] SessionGetInfo(0xb33e40) -> -2147417855 6/18/10 4:14:42 PM /Library/Application Support/MyCompany/MyCompany Agent.app/Contents/MacOS/MyCompany Agent[868] SessionGetInfo(0xb33e40) -> -2147417855
On 20 Aug 2010, at 21:03, Sidney San Martín wrote:
I ran into a machine running OS 10.5.8 recently where our launchd agent and the user's launchd did not terminate at logout.
The per-user launchd does not necessarily quit at logout time. Remember that the per-user launchd runs a variety of different sessions, so it will often remain running to manage those sessions. OTOH the GUI session is supposed to be torn down at logout time, and that should quit your GUI per-user launchd agent. This does work in general (even on 10.5 :-). Can you think of any special about your agent that might be causing this? Are you explicitly loading your agent? If not, one trick I often use is to install TextEdit as a GUI per-user launchd agent. This just requires you to create a minimal launchd property list file for TextEdit. I can then use it to verify that launchd is behaving itself. Once you do that, you should be able to compare your property list file to this dummy one, and your app to TextEdit, and see what's causing the problem. S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
There's nothing special about the agent, and it's loaded by launchd via /Library/LaunchAgents (except after installation). I tried killing it, letting launchd reload it, and logging out and back in, and the issue persisted. It only stopped after a reboot. The author of <http://lists.macosforge.org/pipermail/launchd-dev/2009-January/000477.html> pointed me at hist post; it looks like I'm not the first person to experience this. I like your trick! If I ever get my hands on another machine with these symptoms, I'll give it a shot. Thanks. On Mon, Aug 23, 2010 at 5:31 AM, Quinn "The Eskimo!" <eskimo1@apple.com> wrote:
On 20 Aug 2010, at 21:03, Sidney San Martín wrote:
I ran into a machine running OS 10.5.8 recently where our launchd agent and the user's launchd did not terminate at logout.
The per-user launchd does not necessarily quit at logout time. Remember that the per-user launchd runs a variety of different sessions, so it will often remain running to manage those sessions.
OTOH the GUI session is supposed to be torn down at logout time, and that should quit your GUI per-user launchd agent. This does work in general (even on 10.5 :-). Can you think of any special about your agent that might be causing this? Are you explicitly loading your agent?
If not, one trick I often use is to install TextEdit as a GUI per-user launchd agent. This just requires you to create a minimal launchd property list file for TextEdit. I can then use it to verify that launchd is behaving itself. Once you do that, you should be able to compare your property list file to this dummy one, and your app to TextEdit, and see what's causing the problem.
S+E -- Quinn "The Eskimo!" <http://www.apple.com/developer/> Apple Developer Relations, Developer Technical Support, Core OS/Hardware
_______________________________________________ launchd-dev mailing list launchd-dev@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/launchd-dev
participants (2)
-
Quinn "The Eskimo!"
-
Sidney San Martín