If a process that spawns other processes (like the clang driver) gets killed via a SIGINT, it should wait until its children exit before returning from the signal handler. This prevents the child processes from getting re-parented, which causes problems for build systems that are the parent of clang processes.
Details
- Reviewers
- None
Diff Detail
Event Timeline
lib/Support/Unix/Program.inc | ||
---|---|---|
72 | Do pids ever get pushed onto here? or is that an upcoming patch? |
It doesn't look like ChildPIDs is ever added to?
This implementation can possibly call free() from ChildPIDs->clear(), and
while sys::Wait() looks safe as invoked, I could see how someone might
change it in a way that would cause it to break. It might be safer to call
waitpid() directly, or at least to add a comment to sys::Wait() noting that
it needs to stay signal safe when WaitUntilTerminates == 0 && ErrMsg ==
nullptr.
Also, I think you should take care not to register WaitForChildren()
multiple times.
Probably also good to include a note about why we are waiting for children.
- Daniel
lib/Support/Unix/Program.inc | ||
---|---|---|
209 | This can race on ProgramSignalHandlerAdded. | |
342 | Shouldn't we also make sure to remove (or maybe just clear to 0, to indicate it is gone?) the PID when the child goes away? | |
352 | This comment should be adjusted to not this is only necessary when ErrMsg=0, since the code trivially fails the comment if not. |
Do pids ever get pushed onto here? or is that an upcoming patch?