I wrote startd.plist, which should attach a debugger to WindowServer when it starts. The main body 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 session in which gdb is connected to WindowServer.
However, this seems to cause the error condition in launchd in Snow Leopard, causing it to log error messages:
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 messages "... are not allowed in Mach bootstrap system messages" occur regardless of how much time has passed since the system booted.
Is there a workaround for this so that I can start a screen session?
According to the man page to run,
Daemons should not attempt to display the user interface or interact directly with the user's login session.
This may mean that startd sees this behavior as interacting with another session and denies it. The code is here, but I am not familiar with it: http://launchd.macosforge.org/trac/browser/trunk/launchd/src/launchd_core_logic.c#L8250
source share