From owner-freebsd-hackers Wed Sep 23 11:30:22 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id LAA17100 for freebsd-hackers-outgoing; Wed, 23 Sep 1998 11:30:22 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from rover.village.org (rover.village.org [204.144.255.49]) by hub.freebsd.org (8.8.8/8.8.8) with SMTP id LAA17005 for ; Wed, 23 Sep 1998 11:30:01 -0700 (PDT) (envelope-from imp@village.org) Received: from harmony [10.0.0.6] by rover.village.org with esmtp (Exim 1.71 #1) id 0zLtfj-0001Dq-00; Wed, 23 Sep 1998 12:29:51 -0600 Received: from harmony.village.org (localhost.village.org [127.0.0.1]) by harmony.village.org (8.9.1/8.8.3) with ESMTP id MAA22650; Wed, 23 Sep 1998 12:30:07 -0600 (MDT) Message-Id: <199809231830.MAA22650@harmony.village.org> To: Don Lewis Subject: Re: The inetd realloc problem: an observation Cc: Graham Wheeler , hackers@FreeBSD.ORG In-reply-to: Your message of "Tue, 22 Sep 1998 15:59:39 PDT." <199809222259.PAA19262@salsa.gv.tsc.tdk.com> References: <199809222259.PAA19262@salsa.gv.tsc.tdk.com> Date: Wed, 23 Sep 1998 12:30:06 -0600 From: Warner Losh Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In message <199809222259.PAA19262@salsa.gv.tsc.tdk.com> Don Lewis writes: : I thought of a more elegant way of handling the timeout problem. Before : starting the select loop, create a pipe. Add the fd of the read end of the : pipe to the list of descriptors passed to select. In each of the signal : handlers, write a single character to the pipe in addition to setting the : flag. When select indicates that the pipe has data to read, block : the signals that have handlers, read a character from the pipe, test : and clear each of the flags, execute the appropriate code for each flag, : and unblock signals. We used this in OI to implement a "safe" signal callback. Since we already had a select loop, we just addedt his pipe to the loop. We registered signal handlers and when the signal came in, we'd write the signal number to this pipe. When the select fired, we knew it was a "safe" time to do anything at all, so we called the user's callback. This worked well on all systems that we tested from FreeBSD to Solaris to IRIX. We didn't bother blocking the signals since we didn't care if the signal came in 10 times or once, since we'd have 10 callbacks or one for the user. This worked really well for things like SIGIO and SIGCHLD which the user wanted to catch. Since all we were doing in the signal handler was writing a single byte with a WRITE call, this was safe and portable. I can't take credit for thinking of this. One of the OI users at bbn (later at centerline) sent us this suggestiong back in early 1991 or so. Warner To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message