Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 4 Jun 1998 18:30:01 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        Don.Lewis@tsc.tdk.com (Don Lewis)
Cc:        dk+@ua.net, barry@lustig.com, freebsd-hackers@FreeBSD.ORG, serge@yahoo.com
Subject:   Re: Code Logic Question in 2.2 RELENG
Message-ID:  <199806041830.LAA02825@usr05.primenet.com>
In-Reply-To: <199806040855.BAA06987@salsa.gv.tsc.tdk.com> from "Don Lewis" at Jun 4, 98 01:55:26 am

next in thread | previous in thread | raw e-mail | index | archive | help
> Well, there's a call to perror().  What does it say errno is?  My
> suspicion is that it is ECHILD.  My somewhat dated copy of portmap.c
> has the following code:
> 
> void
> reap()
> {
>         while (wait3((int *)NULL, WNOHANG, (struct rusage *)NULL) > 0);
> }
> 
> If portmap receives two signals closely spaced in time, the first
> signal will interrupt the select() call, and if reap() is called
> after select() has set errno and returned, the wait3() call in reap()
> will stomp errno.  I've fixed similar problems by saving errno at the
> beginning of a signal handler and restoring it at the end.  I'm not
> sure what ANSI and POSIX have to say about this and I don't know if
> you can do this if you are using threads and have a per-thread errno,
> but it has worked for me.

Which reminds me.  Someone needs to fix the "siginterrupt" man page.

I would, but I think it is FreeBSD that is broken, not the man page,
and that by default, system calls *should* be restarted after a
signal is caught.  I find it utterly bogus that I have to springle
the bejesus out of my code for while()'s and tests for "EINTR" and
manually restart all of my system calls.  Gruds, if I wanted that,
I load System V on my box instead of BSD.

In The Good Old Days(tm), it wasn't an option; if you wanted EINTR
type behaviour, you did a setjmp before the call you wanted the
behaviour on, and like a decent, God-fearing BSD'er, you called
longjmp from the signal handler to prevent the call from being
restarted.

Just think how much easier the POSIX threading would be; the user
space pthreads should default to restart behaviour for calls, and
have a seperate handler that queues signals to the schedluer.

[ ...the crusty old BSD hermit slinks back to his cave... ]


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199806041830.LAA02825>