我已经写了一个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。
然而,这似乎触发下雪豹的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
是的,我无法使用LaunchAgents或LaunchDaemons以任何配置(在plist文件中指定用户名和/或用户组)。最终,我最终为使用Automator的个人用户创建了一个登录项目,将shell脚本变为一个应用程序。当然,这不是一个理想的解决方案,但苹果似乎已经在这里阻挠我们。 – Dalmazio 2014-02-20 04:05:44