4

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

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
rgov
  • 3,516
  • 1
  • 31
  • 51
  • Yes, I could't get this to work either with LaunchAgents or LaunchDaemons in any configuration (specifying UserName and/or UserGroup in plist files). Ultimately, I ended up just creating a login item for an individual user using Automator to turn the shell script into an app. Certainly not an ideal solution, but Apple seems to have hamstrung us here. – Dalmazio Feb 20 '14 at 04:05

2 Answers2

1

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
  • 26
  • 1
  • 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 Feb 22 '10 at 02:04
1

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.

  • This did not solve the problem in Mountain Lion. After some research, the problem doesn't appear to be related to screen, but rather launchd not allowing interactive sessions during boot. And 'screen' appears to be considered 'interactive' by launchd. – Dalmazio Feb 20 '14 at 04:10