From owner-freebsd-current Sun Dec 13 14:54:11 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id OAA18896 for freebsd-current-outgoing; Sun, 13 Dec 1998 14:54:11 -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 OAA18890 for ; Sun, 13 Dec 1998 14:54:10 -0800 (PST) (envelope-from tlambert@usr09.primenet.com) Received: (from daemon@localhost) by smtp04.primenet.com (8.8.8/8.8.8) id PAA01500; Sun, 13 Dec 1998 15:54:05 -0700 (MST) Received: from usr09.primenet.com(206.165.6.209) via SMTP by smtp04.primenet.com, id smtpd001476; Sun Dec 13 15:54:04 1998 Received: (from tlambert@localhost) by usr09.primenet.com (8.8.5/8.8.5) id PAA10799; Sun, 13 Dec 1998 15:53:54 -0700 (MST) From: Terry Lambert Message-Id: <199812132253.PAA10799@usr09.primenet.com> Subject: Re: inetd: realloc/free bug To: archie@whistle.com (Archie Cobbs) Date: Sun, 13 Dec 1998 22:53:54 +0000 (GMT) Cc: peter.edwards@isocor.ie, dillon@apollo.backplane.com, jwd@unx.sas.com, freebsd-current@FreeBSD.ORG In-Reply-To: <199812111940.LAA27652@bubba.whistle.com> from "Archie Cobbs" at Dec 11, 98 11:40:58 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-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > I guess I was thinking in terms of the event library model; that is, > you don't handle the signal event in the signal handler (because in > general the event handler could call malloc(), etc), but rather you > simply set a flag (call it "signalFlag"). > > The race condition is getting a signal between the first and second > lines below: > > sigprocmask(SIG_UNBLOCK ..) /* unblock signals */ > r = select(...) /* wait for event */ > sigprocmask(SIG_BLOCK ..) /* block signals */ > > if (signalFlag || r > 0) { > ... /* handle event(s) */ > } > > But there are probably smarter ways to do it than this. Yes. Don't block signals, use a setjmp for the select, and choose system call restart behaviour. The race you are concerned with is a signal occurring before the select starts, and the resulting EINTR. 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