[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

signals and atomicity



hi, i found the following code in apache web server code.

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 :-(

now perhaps it is not interesting, wether the wait call succeeded, because
you can start it again. but what about a call to "read()" ? i MUST know,
wether it worked or wether it was interrupted by a signal!

byebye
Erik

o-------------------- snap
static JMP_BUF wait_timeout_buf;  static int wait_or_timeout_retval = -1; 

static void longjmp_out_of_alarm (int sig) {
    siglongjmp (wait_timeout_buf, 1); 
}

int wait_or_timeout (int *status) {
    wait_or_timeout_retval = -1; 

    if (sigsetjmp(wait_timeout_buf, 1) != 0) {
        errno = ETIMEDOUT; 
        return wait_or_timeout_retval; 
    }

    signal (SIGALRM, longjmp_out_of_alarm); 
    alarm(1);
    wait_or_timeout_retval = wait(status);
    alarm(0); 
    return wait_or_timeout_retval; 
}
o----------------------- snip


--
To UNSUBSCRIBE, email to debian-devel-request@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


Reply to: