In article <[EMAIL PROTECTED]> you wrote: > On Sat, 18 Apr 1998, Herbert Xu wrote: >> 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; >> }
> i do not think, this works. > alarm() calls setitimer(). setitimer() modifies "errno". > so, setting errno inside the signal handler does not work, i think. That's easy to fix. Just store ETIMEDOUT in some other variable that is reset at the start of wait_or_timeout and store the result in errno if wait fails with EINTR. -- 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]