views:

198

answers:

2

I've written a launchd .plist which should attach a debugger to the WindowServer when it launches. The main part of the script looks like

screen -D -m -S "WindowServer Debugger" \
gdb \
-x $GDBSCRIPT \
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/WindowServer \
$WSPID

This starts a detached screen session in which gdb is attached to WindowServer.

However, this seems to trigger an error condition in launchd under Snow Leopard, causing it to spout out error messages to the log:

com.apple.launchd[1] (0x10011c070.anonymous.screen[961]) Bug: launchd_core_logic.c:8250 (23932):0
com.apple.launchd[1] (0x10011c070.anonymous.screen[961]) Switching sessions is not allowed in the system Mach bootstrap.
com.apple.launchd[1] (0x10011c070.anonymous.screen[961]) _vprocmgr_switch_to_session(): kr = 0x44c

I should note that the "... not allowed in the system Mach bootstrap" messages occur regardless of how long it has been since system boot.

Is there a workaround to this so that I can spawn my screen session?

According to the manpage for launchd,

Daemons should not attempt to display UI or interact directly with a user's login session.

This might suggest that launchd is seeing this behavior as interacting with another session and denying it. The code is here but I'm not familiar with it: http://launchd.macosforge.org/trac/browser/trunk/launchd/src/launchd_core_logic.c#L8250

A: 

Apparently you can't detach (using -D) in the system bootstrap. You could do this in a launchagent (or otherwise within your user bootstrap).

Bill
Yes, but if I don't detach (using -D or -d), then screen complains that I don't have a tty.Since the WindowServer runs as a different user, I don't think I can just make a LaunchAgent for it.
rgov
A: 

I was experiencing this problem using screen version 4.0.3. I built the latest version available (4.1.dev) on git://git.sv.gnu.org/screen.git and that fixed the problem for me.

blue_beastie