从启动守护程序产生屏幕会话 [英] Spawn a screen session from launch daemon

查看:84
本文介绍了从启动守护程序产生屏幕会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个启动的.plist,它应该在启动WindowServer时将调试器附加到WindowServer上.脚本的主要部分看起来像

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

这将启动一个分离的屏幕会话,其中gdb附加到WindowServer.

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

但是,这似乎触发了在Snow Leopard下启动时的错误情况,导致它向日志发出错误消息:

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

我应该注意,无论自系统启动以来已有多长时间,都会出现"...不允许在系统中进行Mach引导"消息.

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?

根据要启动的手册页,

守护程序不应尝试显示UI或直接与用户的登录会话进行交互.

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

这可能表明launchd将此行为视为与另一个会话进行交互并拒绝它.代码在这里,但我不熟悉: http://launchd.macosforge.org/trac/browser/trunk/launchd/src/launchd_core_logic.c#L8250

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

推荐答案

显然,您无法在系统引导程序中分离(使用-D).您可以在启动代理中执行此操作(或在用户引导程序中执行此操作).

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

这篇关于从启动守护程序产生屏幕会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆