From 220cd21a6907b86c5b3e75ec6c5fd91d27599b56 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Mon, 25 Jan 2010 23:26:07 +0000 Subject: Explicitly ignore SIGCHLD signal by sending it to an empty function so that the boost_unit_test framework doesn't catch the signal when child processes exit git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@903008 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/tests/ForkedBroker.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'cpp') 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 -- cgit v1.2.1