Add SIG_CHLD signal handler back, and remove SIG_IGN.

This commit is contained in:
Zhang Qinghua 2020-09-19 21:13:21 +08:00
parent 55751c6c33
commit 28d7ab48a8
2 changed files with 7 additions and 1 deletions

View File

@ -152,7 +152,7 @@ void DuplexPipe::Close() {
DuplexPipe::SignalHandler::SignalHandler(std::shared_ptr<DuplexPipe> dp, pid_t pid) {
dp_ = dp;
child_pid_ = pid;
signal(SIGCHLD, SIG_IGN);
signal(SIGCHLD, SigChildHandler);
signal(SIGPIPE, SigPipeHandler);
}
@ -178,4 +178,9 @@ void DuplexPipe::SignalHandler::SigPipeHandler(int sig) {
dp_->NotifyFinalize();
}
}
void DuplexPipe::SignalHandler::SigChildHandler(int sig) {
int status;
(void)waitpid(child_pid_, &status, WNOHANG | WUNTRACED);
}
} // namespace mindspore

View File

@ -118,6 +118,7 @@ class DuplexPipe : public std::enable_shared_from_this<mindspore::DuplexPipe> {
private:
static void SigAlarmHandler(int sig);
static void SigPipeHandler(int sig);
static void SigChildHandler(int sig);
inline static std::shared_ptr<DuplexPipe> dp_;
inline static pid_t child_pid_;