-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Terminate subprocesses when changes are received in watch (#599).
Interestingly they now seem to be getting a SIGINT when I ctrl+c the parent, although I haven't done anything explicit to handle that?
- Loading branch information
1 parent
b8f7ea8
commit 594a0ec
Showing
4 changed files
with
27 additions
and
14 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
594a0ec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - This is much more straightforward than my implementation!
One unfortunate side-effect that I've noticed -
exec.CommandContext()
only kills the process, not the process group. The result is that processes started by the build target are left running - I noticed this because my process-under-test is a wrapper shell-script whose job is mostly just to kick off another process.There is this comment for
exec.CommandContext
:Looking at
os.Process.Kill
, we find the following:This feels like a bad match for
plz
. It's not clear to me whether there's a mechanism to achieve different behavior (i.e. kill all subprocesses), or whether this makes context-based cancellation a mismatch for the use-case here - Trying to poke around and see.What do you think?
594a0ec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, makes sense. Agreed that Go's builtins are a little basic - we do some stuff in
core
with process groups to try to help this (used to usePdeathsig
but that's less general and only worked on Linux anyway).On balance I still like a context as a general mechanism for managing its lifetime, but maybe we should forego
CommandContext
, setSetpgid
on the new process and do our own killing of the group when the context expires. Does that make sense?594a0ec
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had an idea for how to work around this, and put it in my #600 PR. What do you think? Seems to work well on my system, and definitely simpler than what I had the first time around :-)