Add stop signals to client threads

This commit is contained in:
Alex Young
2012-06-07 11:44:19 +01:00
parent cfa9f9c71f
commit a90f84972b
13 changed files with 417 additions and 100 deletions

View File

@@ -100,21 +100,25 @@ int self_pipe_signal( struct self_pipe * sig )
/**
* Clear a received signal from the pipe. Every signal sent must be
* cleared by one (and only one) recipient when they return from select().
* Returns the number of bytes read, which will be 1 on success and 0 if
* there was no signal.
*/
int self_pipe_signal_clear( struct self_pipe *sig )
{
char buf[1];
read( sig->read_fd, buf, 1 );
return 1;
return read( sig->read_fd, buf, 1 );
}
/**
* Close the pipe and free the self_pipe. Do not try to use the
* self_pipe struct after calling this, the innards are mush.
*/
int self_pipe_destroy( struct self_pipe * sig )
{
NULLCHECK(sig);
while( close( sig->read_fd ) == -1 && errno == EINTR );
while( close( sig->write_fd ) == -1 && errno == EINTR );