forked from neovim/neovim
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
job-control: do system() and :! in Nvim's process-group
(This commit is for reference; the functional change will be reverted.) ref neovim#8217 ref neovim#8450 ref neovim#8678 In terminal-Vim, system() and :! run in Vim's process-group. But 8d90171 changed all of Nvim's process-spawn utilities to do setsid(), which conflicts with that expected terminal-Vim behavior. To "fix" that, this commit defines Process.detach as a TriState, then handles the kNone case such that system() and :! do not do setsid() in the spawned child. But this commit REGRESSES 8d90171 (neovim#8107), so for example the following code causes orphan processes: :echo system('sleep 30|sleep 30|sleep 30') Q: If we don't create a new session/process-group, how to avoid zombie descendants (e.g. process_wait() calls process_stop(), which only kills the root process)? A: Vim's approach in mch_call_shell_fork() is: 1. BLOCK_SIGNALS (ignores deadly) 2. fork() 3. unblock signals in the child 4. On CTRL-C, send SIGINT to the process-group id: kill(-pid, SIGINT) 5. Parent (vim) ignores the signal. Child (and descendants) do not. https://github.com/vim/vim/blob/e7499ddc33508d3d341e96f84a0e7b95b2d6927c/src/os_unix.c#L4834-L4841 https://github.com/vim/vim/blob/e7499ddc33508d3d341e96f84a0e7b95b2d6927c/src/os_unix.c#L5122-L5134 But we can't do that if we want to use the existing (libuv-based) form of process_spawn().
- Loading branch information
Showing
9 changed files
with
86 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters