我编写了一个launchd .plist,它应该在WindowServer 启动时附加一个调试器。脚本的主要部分看起来像
screen -D -m -S "WindowServer Debugger" \
gdb \
-x $GDBSCRIPT \
/System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/CoreGraphics.framework/Versions/A/Resources/WindowServer \
$WSPID
这将启动一个分离的屏幕会话,其中 gdb 连接到 WindowServer。
但是,这似乎在 Snow Leopard 下的 launchd 中触发了一个错误条件,导致它向日志中输出错误消息:
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
我应该注意,无论系统启动以来已经过了多长时间,都会出现“......系统Mach引导程序中不允许”消息。
是否有解决方法,以便我可以生成我的屏幕会话?
根据launchd的手册页,
守护进程不应尝试显示 UI 或直接与用户的登录会话交互。
这可能表明 launchd 将此行为视为与另一个会话交互并拒绝它。代码在这里,但我不熟悉: http: //launchd.macosforge.org/trac/browser/trunk/launchd/src/launchd_core_logic.c#L8250