Gordon Molek
|
Weird (apparent) interaction between sockets and signals?
|
Gordon Molek
10/08/2009 12:17 PM
post39612
|
Weird (apparent) interaction between sockets and signals?
We have an application where the main thread sets up a signal handling function for SIGTERM, spawns a secondary thread
using pthread_create() and then calls pause() waiting for a SIGTERM to arrive. The secondary thread will attempt to
create an outgoing TCP connection (POP3), attempt to retrieve e-mails from the server, close the connection and then
sleep for a specified interval before trying again.
The weird behavior is that if we give the invalid IP address of "0.0.0.0" everything works as expected, no e-mails are
retrieved, but the application exits gracefully when a SIGTERM is sent to it. However, if we have a valid IP address
configured, the signal appears to cause the sleeping secondary thread to wake up, not the paused primary thread. Is
there some strange interaction between the sockets library and the signals handling code? If so, how do we resolve this
?
Thanks,
Gordon Molek
Zebra Technologies Corp.
|
|
|