From owner-freebsd-hackers Thu Jun 4 11:30:49 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA02250 for freebsd-hackers-outgoing; Thu, 4 Jun 1998 11:30:49 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp03.primenet.com (daemon@smtp03.primenet.com [206.165.6.133]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id LAA02122 for ; Thu, 4 Jun 1998 11:30:22 -0700 (PDT) (envelope-from tlambert@usr05.primenet.com) Received: (from daemon@localhost) by smtp03.primenet.com (8.8.8/8.8.8) id LAA11511; Thu, 4 Jun 1998 11:30:15 -0700 (MST) Received: from usr05.primenet.com(206.165.6.205) via SMTP by smtp03.primenet.com, id smtpd011437; Thu Jun 4 11:30:10 1998 Received: (from tlambert@localhost) by usr05.primenet.com (8.8.5/8.8.5) id LAA02825; Thu, 4 Jun 1998 11:30:01 -0700 (MST) From: Terry Lambert Message-Id: <199806041830.LAA02825@usr05.primenet.com> Subject: Re: Code Logic Question in 2.2 RELENG To: Don.Lewis@tsc.tdk.com (Don Lewis) Date: Thu, 4 Jun 1998 18:30:01 +0000 (GMT) Cc: dk+@ua.net, barry@lustig.com, freebsd-hackers@FreeBSD.ORG, serge@yahoo.com In-Reply-To: <199806040855.BAA06987@salsa.gv.tsc.tdk.com> from "Don Lewis" at Jun 4, 98 01:55:26 am X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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