Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#! /usr/bin/perl -wT use POSIX(); use strict; require 5.008; sub zap { $SIG{CHLD} = \&zap; # loathe sysV, dream of real POSIX while (my $pid = waitpid(-1, POSIX::WNOHANG())) { last unless $pid>0; if ($? != 256) { die("Caught a $?"); } } } $SIG{CHLD} = \&zap; my ($pid); while (1) { FORK: foreach (1..4) { if ($pid = fork) { } elsif (defined $pid) { sleep 1; exit 1; } elsif ($! =~ /No more process/) { sleep 5; redo FORK; } else { die("Can't fork"); } } } __DATA__ perl -V gives Summary of my perl5 (revision 5.0 version 8 subversion 0) configuratio +n: Platform: osname=solaris, osvers=2.8, archname=sun4-solaris-thread-multi uname='sunos hostname 5.8 generic_108528-15 sun4u sparc sunw,sun-b +lade-100 ' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemulti +plicity=define useperlio=define d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -fno-strict-aliasing -D_LARGEFILE_ +SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O', cppflags='-D_REENTRANT -fno-strict-aliasing' ccversion='', gccversion='3.2.2', gccosandvers='solaris2.8' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +6 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -L/usr/local/lib ' libpth=/usr/local/lib /usr/lib /usr/ccs/lib libs=-lsocket -lnsl -ldl -lm -lrt -lpthread -lc perllibs=-lsocket -lnsl -ldl -lm -lrt -lpthread -lc libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-G -L/usr/local/lib'
update (broquaint): changed <pre> to <code> + added formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Signal Handling problems in 5.8
by tilly (Archbishop) on Jun 23, 2003 at 07:39 UTC | |
|
Re: Signal Handling problems in 5.8
by perlplexer (Hermit) on Jun 23, 2003 at 21:23 UTC |