#! /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) configuration: Platform: osname=solaris, osvers=2.8, archname=sun4-solaris-thread-multi uname='sunos hostname 5.8 generic_108528-15 sun4u sparc sunw,sun-blade-100 ' config_args='' hint=recommended, useposix=true, d_sigaction=define usethreads=define use5005threads=undef useithreads=define usemultiplicity=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=16 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'