Date: Sun, 13 Dec 1998 22:53:54 +0000 (GMT) From: Terry Lambert <tlambert@primenet.com> To: archie@whistle.com (Archie Cobbs) Cc: peter.edwards@isocor.ie, dillon@apollo.backplane.com, jwd@unx.sas.com, freebsd-current@FreeBSD.ORG Subject: Re: inetd: realloc/free bug Message-ID: <199812132253.PAA10799@usr09.primenet.com> In-Reply-To: <199812111940.LAA27652@bubba.whistle.com> from "Archie Cobbs" at Dec 11, 98 11:40:58 am
next in thread | previous in thread | raw e-mail | index | archive | help
> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812132253.PAA10799>