Boost logo

Boost :

Subject: Re: [boost] Subject: Formal Review of Proposed Boost.Process library starts tomorrow
From: Oliver Kowalke (k-oli_at_[hidden])
Date: 2011-02-10 13:49:36


Am 10.02.2011 17:11, schrieb Artyom:
>> sigset_t set;
>> sigemptyset(& set),
>> sigaddset(& set, SIGCHLD); // SIGTERM, SIGINT, SIGQUIT
>> pthread_sigmask(SIG_BLOCK,& set, ...);
>> int signo( 0);
>> sigwait( set,& signo);
>> switch ( signo)
>> {
>> case SIGCHLD:
>> while (true)
>> {
>> int status( 0);
>> pid_t child = waitpid(
>> -1, % status, WUNTRACED|WCONTINUED);
>> if ( -1 == child&& ECHILD != child)
>> throw runtime_error("waitpid() failed");
>> // select data/callabck associated with child
>> // from internal storage
>> }
>> case: ...
>> };

correction:

if ( -1 == child) {
   if ( ECHILD == child) {
     break; // return to sigwait()
   else {
     throw runtime_error("waitpid() failed");
   }
}
// select data/callabck associated with child
// from internal storage

I suggest to wait for SIGUSR1 in sigwait() which indicates that the wait
function should be canceld. pthread_kill() can be used to send the
SIGUSR1 to the worker-thread.

Oliver


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk