Create a screen session from the start daemon

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

+4
source share
2 answers

I ran into this problem using screen version 4.0.3. I built the latest version (4.1.dev) on git: //git.sv.gnu.org/screen.git and this fixed the problem for me.

+1
source

Apparently you cannot disconnect (using -D) in the system bootstrap. You can do this in the start agent (or otherwise as part of a custom bootstrap).

0
source

Source: https://habr.com/ru/post/1301937/


All Articles