mirror of
https://github.com/arun11299/cpp-subprocess.git
synced 2025-08-06 05:16:24 -04:00
fix a bug of defunct process by adding a SIGCHLD handler.
This commit is contained in:
parent
a23c1033df
commit
814be9e635
@ -42,6 +42,7 @@ Documentation for C++ subprocessing libraray.
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <cstdio>
|
||||
#include <csignal>
|
||||
#include <future>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
@ -1150,6 +1151,11 @@ void Popen::execute_process() throw (CalledProcessError, OSError)
|
||||
}
|
||||
exe_name_ = vargs_[0];
|
||||
|
||||
std::signal(SIGCHLD, [](int sig){
|
||||
int status;
|
||||
waitpid(-1, &status, WNOHANG);
|
||||
});
|
||||
|
||||
child_pid_ = fork();
|
||||
|
||||
if (child_pid_ < 0) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user