home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!malgudi.oar.net!chemabs!jon
- From: jon@cas.org (Jon Vander Hill)
- Subject: Re: timing problem with $SIG{'CHLD'}
- In-Reply-To: ccechk@nuscc.nus.sg's message of Fri, 11 Dec 1992 07:33:01 GMT
- Message-ID: <JON.92Dec12073444@cas.org>
- Sender: usenet@cas.org
- Organization: Chemical Abstracts Service, Columbus, Ohio
- References: <1992Dec7.112748.24164@hemlock.cray.com> <1992Dec11.073301.29314@nuscc.nus.sg>
- Date: Sat, 12 Dec 1992 12:34:44 GMT
- Lines: 42
-
- >>>>> On Fri, 11 Dec 1992 07:33:01 GMT, ccechk@nuscc.nus.sg (Heng Kek) said:
-
- > mlo@cray.com (Mick Oyer) writes:
- > : I'm trying to set up a daemon, written in perl, that will listen
- > : for messages coming across the network. I used the client/server
- > : model in the Camel book as a starting point, but am running into
- > : a sticky situation.
- > :
- > [..deleted..]
- > : I'm setting $SIG{'CHLD'} to reap the zombies.
- > : The problem:
- > : my code is blocking on the 'accept' call. When the child
- > : exits, the CHLD signal causes reaper to get called, interfering
- > : with the accept:
- > : Interrupted system call at ./modinfod line 45.
- > :
- > : (line 45): ($addr = accept(NS,S)) || die $!;
- > :
-
- > I had EXACTLY the same problem. My work-around was to re-invoke
- > 'accept()' when it dies as per the problem above. I use:
-
- > ($addr = accept(KK,S)) || ($addr = accept(KK,S)) ||
- > die "accept:$!\n";
- > # ..to avoid accept() dying and killing the prog.
-
- > Any criticism on this method is most welcome as I'd like to learn
- > too.
-
- Here's an alternative approach:
-
- for(;;) {
- $addr = accept(NS,S);
- if (!defined $addr) {
- next if $! =~ /^Interrupted/;
- die "$0: accept failed: $!\n";
- }
- ...
- }
-
- Jon Vander Hill
- jon@cas.org
-