Hello -
I am attempting to get a thread running which will be responsible for detecting a signal from any other thread within the same process.
sigset_t sigset;
sigfillset(&sigset);
pthread_sigmask( SIG_BLOCK, &sigset, &old );
Once i've done this, I then daemonize the process:
m_child = fork();
if (m_child == 0)
{
// Start the thread responsible for detecting a signal
}
This is done within another class called "SignalHandler" where the kick-off to this thread is done as follows:
m_pThread = new boost::thread( boost::bind(&SignalHandler::operator(), this ) );
and the functor operates in a tight loop as follows:
while (1)
{
if ( sigtimedwait( &sigset, &info, &ts ) == -1 )
{
if ( errno == EAGAIN || errno == EINTR )
{
std::cout << "Time-out waiting for signal" << std::endl;
}
throw SystemError( "sigtimedwait error" );
}
else
{
std::cout << "Detected a signal [" << info.si_signo << "]" << std::endl;
}
}
This works when I do a "kill -9 myProcess", but when I actually perform some illegal pointer manipulation (in any other thread), the process core dumps.
Why is the signal produced by the child thread not caught in my boost signal-catching thread?