In article <[EMAIL PROTECTED]> you wrote:

> if the signal occurs after the wait system call, but before the result of
> the system call is stored in "wait_or_timeout_retval", the fact, that
> the system call succeeded is lost.

> this is (1) a bug in apache and (2) a problem of me that i want to solve.
> i thought others would have solved it, but this is obviously not true :-(

This should work:

static int wait_or_timeout_retval = -1;

static void alarm_handler(int sig) {
        errno = ETIMEDOUT; 
}

int wait_or_timeout (int *status) {
        struct sigaction act;

        wait_or_timeout_retval = -1; 

        sigaction(SIGALRM, 0, &act);
        act.sa_handler = alarm_handler;
        act.sa_flags &= ~SA_RESTART;
        sigaction(SIGALRM, &act, 0);
        alarm(1);
        wait_or_timeout_retval = wait(status);
        alarm(0); 
        return wait_or_timeout_retval; 
}

-- 
Debian GNU/Linux 1.3 is out! ( http://www.debian.org/ )
Email:  Herbert Xu ~{PmV>HI~} <[EMAIL PROTECTED]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to