We've been investigating an issue [1] where, given a single attached
screen session, "pkill -TERM screen" leaves the terminal in a broken
state on macOS.
Turns out that on macOS, pgrep/pkill match against argv[0], so the
above command kills only the attacher process, not the forked server
where argv[0]="SCREEN".
Then we are in a broken state because two different processes are
trying to read from the terminal.

I don't really know what the behavior should be but I guess it would
be nice if there was a way to automatically detect/fix this case.

We could automatically detach on SIGTERM as we do on SIGHUP (probably
not worth the trouble though)
Or perhaps there is a way to detect that two shells are racing to
read from the terminal?

[1]: https://github.com/fish-shell/fish-shell/issues/10717
     Originally reported about "pkill -KILL" but whether we can/want
     to also fix that is another story.

Reply via email to