Browse Source

Add SIG_CHLD signal handler back, and remove SIG_IGN.

tags/v1.0.0
Zhang Qinghua 5 years ago
parent
commit
28d7ab48a8
2 changed files with 7 additions and 1 deletions
  1. +6
    -1
      mindspore/ccsrc/common/duplex_pipe.cc
  2. +1
    -0
      mindspore/ccsrc/common/duplex_pipe.h

+ 6
- 1
mindspore/ccsrc/common/duplex_pipe.cc View File

@@ -152,7 +152,7 @@ void DuplexPipe::Close() {
DuplexPipe::SignalHandler::SignalHandler(std::shared_ptr<DuplexPipe> dp, pid_t pid) { DuplexPipe::SignalHandler::SignalHandler(std::shared_ptr<DuplexPipe> dp, pid_t pid) {
dp_ = dp; dp_ = dp;
child_pid_ = pid; child_pid_ = pid;
signal(SIGCHLD, SIG_IGN);
signal(SIGCHLD, SigChildHandler);
signal(SIGPIPE, SigPipeHandler); signal(SIGPIPE, SigPipeHandler);
} }


@@ -178,4 +178,9 @@ void DuplexPipe::SignalHandler::SigPipeHandler(int sig) {
dp_->NotifyFinalize(); dp_->NotifyFinalize();
} }
} }

void DuplexPipe::SignalHandler::SigChildHandler(int sig) {
int status;
(void)waitpid(child_pid_, &status, WNOHANG | WUNTRACED);
}
} // namespace mindspore } // namespace mindspore

+ 1
- 0
mindspore/ccsrc/common/duplex_pipe.h View File

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


inline static std::shared_ptr<DuplexPipe> dp_; inline static std::shared_ptr<DuplexPipe> dp_;
inline static pid_t child_pid_; inline static pid_t child_pid_;


Loading…
Cancel
Save