[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: signal() behavior



Howard Chu wrote:
> Thanks for the response, Mark. With that hint, I have a working kludge.
> In daemon_init, open a pipe that is never used for anything, but include it
> in the set of readfds. In the signal handler, close the write side of the
> pipe - select will return at that point.

"When writing threaded code, treat signals as Jabberwocks--
curious and pontentially dangerous creaters to be approached
caution, if at all."
	David R Butenhof, "Programming with POSIX Threads"

Calling close(2) *should* be safe per POSIX... but then again,
the pthread_kill() in handler *should* have reached the listener
thread per POSIX...

Note, if you having trouble with shutdown... I assume you would
also be having trouble with SIGHUPs as well.  One could use
the pipe to wake the listener in this case as well (though
I'd suggest writing a character to the pipe on each SIGHUP).

BTW, anyone modifying the signal(2) code to move towards sigaction(2)
might also handle the move from select(2) to poll(2).

Kurt