diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/tests/ForkedBroker.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cpp/src/tests/ForkedBroker.cpp b/cpp/src/tests/ForkedBroker.cpp index e1a96c8e90..7c81d303fc 100644 --- a/cpp/src/tests/ForkedBroker.cpp +++ b/cpp/src/tests/ForkedBroker.cpp @@ -89,11 +89,28 @@ bool isLogOption(const std::string& s) { ); } +namespace { + void ignore_signal(int) + { + } +} + void ForkedBroker::init(const Args& userArgs) { using qpid::ErrnoException; port = 0; int pipeFds[2]; if(::pipe(pipeFds) < 0) throw ErrnoException("Can't create pipe"); + + // Ignore the SIGCHLD signal generated by an exitting child + // We will clean up any exitting children in the waitpid above + // This should really be neater (like only once not per fork) + struct ::sigaction sa; + sa.sa_handler = ignore_signal; + ::sigemptyset(&sa.sa_mask); + ::sigaddset(&sa.sa_mask, SIGCHLD); + sa.sa_flags = SA_NOCLDSTOP | SA_RESTART; + ::sigaction(SIGCHLD, &sa, 0); + pid = ::fork(); if (pid < 0) throw ErrnoException("Fork failed"); if (pid) { // parent |