fix a bug of defunct process by adding a SIGCHLD handler.

This commit is contained in:
yytdfc 2017-08-04 11:14:34 +08:00
parent a23c1033df
commit 814be9e635

View File

@ -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) {