diff --git a/mindspore/ccsrc/common/duplex_pipe.cc b/mindspore/ccsrc/common/duplex_pipe.cc index c2f53d574c..c537591cde 100644 --- a/mindspore/ccsrc/common/duplex_pipe.cc +++ b/mindspore/ccsrc/common/duplex_pipe.cc @@ -152,7 +152,7 @@ void DuplexPipe::Close() { DuplexPipe::SignalHandler::SignalHandler(std::shared_ptr 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 diff --git a/mindspore/ccsrc/common/duplex_pipe.h b/mindspore/ccsrc/common/duplex_pipe.h index d99c2906ea..fe069f8dd7 100644 --- a/mindspore/ccsrc/common/duplex_pipe.h +++ b/mindspore/ccsrc/common/duplex_pipe.h @@ -118,6 +118,7 @@ class DuplexPipe : public std::enable_shared_from_this { private: static void SigAlarmHandler(int sig); static void SigPipeHandler(int sig); + static void SigChildHandler(int sig); inline static std::shared_ptr dp_; inline static pid_t child_pid_;