[llvm] [llvm-exegesis] Kill process that recieve a signal (PR #86069)
Clement Courbet via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 21 05:06:21 PDT 2024
================
@@ -342,7 +342,7 @@ class SubProcessFunctionExecutorImpl
return make_error<Failure>("Failed to attach to the child process: " +
Twine(strerror(errno)));
- if (wait(NULL) == -1) {
+ if (waitpid(ParentOrChildPID, NULL, 0) == -1) {
----------------
legrosbuffle wrote:
At that point `ParentOrChildPID` is always the parent, but it's not immediately obvious (I had to scroll up). What about restructuring this function to have:
```
[[noreturn]] void runChildSubprocess(int ReadFD, int FriteFD) {
// We are in the child process, close the write end of the pipe.
close(PipeFiles[1]);
// Unregister handlers, signal handling is now handled through ptrace in
// the host process.
sys::unregisterHandlers();
prepareAndRunBenchmark(PipeFiles[0], Key);
llvm_unreachable("Child process didn't exit when expected.");
}
Error runParentSubprocess(pid_t PID, int ReadFD, int FriteFD) {
const ExegesisTarget &ET = State.getExegesisTarget();
...
}
createSubProcessAndRunBenchmark() {
...
if (ParentOrChildPID == -1) {
...
}
if (ParentOrChildPID == 0) {
runChildSubprocess(PipeFiles[0], Pipefiles[1]);
llvm_unreachable("Child process didn't exit when expected.");
}
return runParentSubprocess(ParentOrChildPID, PipeFiles[0], Pipefiles[1]);
}
```
https://github.com/llvm/llvm-project/pull/86069
More information about the llvm-commits
mailing list