Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Dec 1998 11:40:58 -0800 (PST)
From:      Archie Cobbs <archie@whistle.com>
To:        peter.edwards@isocor.ie (Peter Edwards)
Cc:        dillon@apollo.backplane.com, jwd@unx.sas.com, freebsd-current@FreeBSD.ORG
Subject:   Re: inetd: realloc/free bug
Message-ID:  <199812111940.LAA27652@bubba.whistle.com>
In-Reply-To: <3670EC02.D35D99CC@isocor.ie> from Peter Edwards at "Dec 11, 98 01:55:14 am"

next in thread | previous in thread | raw e-mail | index | archive | help
Peter Edwards writes:
> > It's not trivial if you want to guarantee that no signals are missed.
> > There's no way atomically to: unblock signals and call select().
> 
> Hmm. I must be twisted. 
> What horror results from doing this in a signal handler? On e-paper, it
> seems to give the desired effect, but does a return from a signal
> handler implicitly call sigreturn(2) when it returns? And if so, is
> there anything that requires this to happen?

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.

-Archie

___________________________________________________________________________
Archie Cobbs   *   Whistle Communications, Inc.  *   http://www.whistle.com

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?199812111940.LAA27652>