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 10:57:14


Am 10.02.2011 15:03, schrieb Artyom:
> Probably it would be ok to provide some parameter
> on how to wait asynchronously:
>
> typedef enum {
> wait_default, // using thread+waitpid per-process on POSIX OS
> wait_using_sigaction, // install signal handler
> wait_using_sigwaitinfo, // install signal handler
> wait_polling, // poll all waiting pids for end, when
> // requested - for example by user's signal
> // handler
> } wait_method_type;
>
>
>
> void async_wait(pid ,method_type m = wait_default)
> #ifdef BOOST_POSIX
> void poll_handlers(); // check if child completed
> // called by user when receives sigchld
> endif

what about this solution (without error handling) on POSIX in one
special worker-thread:

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: ...
};

Oliver


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