From owner-freebsd-current Sun Dec 13 14:44:50 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id OAA18164 for freebsd-current-outgoing; Sun, 13 Dec 1998 14:44:50 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from smtp04.primenet.com (smtp04.primenet.com [206.165.6.134]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id OAA18159 for ; Sun, 13 Dec 1998 14:44:49 -0800 (PST) (envelope-from tlambert@usr09.primenet.com) Received: (from daemon@localhost) by smtp04.primenet.com (8.8.8/8.8.8) id PAA28907; Sun, 13 Dec 1998 15:44:40 -0700 (MST) Received: from usr09.primenet.com(206.165.6.209) via SMTP by smtp04.primenet.com, id smtpd028850; Sun Dec 13 15:44:34 1998 Received: (from tlambert@localhost) by usr09.primenet.com (8.8.5/8.8.5) id PAA10383; Sun, 13 Dec 1998 15:44:29 -0700 (MST) From: Terry Lambert Message-Id: <199812132244.PAA10383@usr09.primenet.com> Subject: Re: inetd: realloc/free bug To: dillon@apollo.backplane.com (Matthew Dillon) Date: Sun, 13 Dec 1998 22:44:29 +0000 (GMT) Cc: archie@whistle.com, jwd@unx.sas.com, freebsd-current@FreeBSD.ORG In-Reply-To: <199812110659.WAA35073@apollo.backplane.com> from "Matthew Dillon" at Dec 10, 98 10:59:07 pm 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-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > :> If you put a time limit on select(), it doesn't matter if there is a > :> race condition there. How does select() cause a signal to be missed ? > : > :Well, sure.. :-) but then you don't service signals in real time > :and spend extra cycles timing out all the time. > > You do serve signals in real time... the signals are *unmasked* during > the select() :-) ... the race condition is that the unmasked signal may > cause the descriptor set to be changed just prior to the select() call, > causing select() to wait forever. The timeout on the select() handles > the race condition without effecting the realtime delivery of signals. You should just use siginterrupt(3) to make sure select restarts, and be done with it. If you need to interrupt the select after setting system call restart behaviour, then use a longjmp from the signal handler after setting a volatile flag so that the flag can be tested in the "else" case of the setjmp() call. If the call is restarted, you don't have to worry about the timer, it will do the right thing, and you won't get an EINTR that you con't know how to handle the masks around. If you don't like siginterrupt(3), and want to use the non-Berkeley signal mechanisms for setting call restart behaviour, then be my guest and write 30 or 40 lines of POSIX expecting code instead. The siginterrupt(2) system call first appeared in BSD 4.1c; the current code uses POSIX sigaction(2); someone might want to correct the siginterrupt(3) man page... 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-current" in the body of the message