Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/17/84 chuqui version 1.7 9/23/84; site cadtec.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!ihnp4!houxm!vax135!cornell!uw-beaver!tektronix!hplabs!nsc!cadtec!rick From: rick@cadtec.UUCP (Rick Auricchio) Newsgroups: net.unix-wizards Subject: Help with select(2) and SIGCHLD together Message-ID: <105@cadtec.UUCP> Date: Wed, 15-May-85 16:51:34 EDT Article-I.D.: cadtec.105 Posted: Wed May 15 16:51:34 1985 Date-Received: Fri, 24-May-85 02:03:58 EDT Reply-To: rick@cadtec.UUCP (Rick Auricchio) Distribution: net Organization: Cadtec Corp., San Jose CA Lines: 45 -------- [] The requirement: to "watch" a file descriptor [technically, a socket for pending connects] via select(2), AND to catch SIGCHLD signals; ----------- Current thoughts: for (;;) { oldmask = sigblock(1 << (SIGCHLD - 1)); /* block SIGCHLD */ ... scan tables for dead children and do whatever... sigsetmask(oldmask); /* allow SIGCHLD */ n = select(fd,&fdmask,0,0,0); /* wait for activity */ switch (n) { case -1 : ...oops!... case 0 : break; /* SIGCHLD occurred, recheck tables */ case 1 : ... do socket accept etc... } } sigchldcatcher() { ...simply mark tables appropriately (nothing else!)... } ------------ The Problem: An interruptibility window exists between the sigsetmask() and the select(), which could cause me to miss a signal till the next time an event terminates/interrupts the select. One (ugly) solution is to have the select timeout and then re-select if nothing's happened. But this wastes CPU time. The original design didn't have to select at all, so the sigsetmask was actually a sigpause(oldmask) which worked fine... Any ideas? ============================================================================== Opinions expressed have been generated solely by line-noise. {cbosgd,decwrl,hplabs,ihnp4,seismo}!nsc!cadtec!rick N1150G (408) 942-1535 "It only rains when you have something planned."