#!/usr/bin/perl use strict; use POSIX ":sys_wait_h"; sub REAPER { 1 until waitpid(-1, WNOHANG) == -1 } $SIG{CHLD} = \&REAPER; my $run = 0; while (1) { my $pid = fork; if (defined $pid && $pid == 0) { # child my $gna; # demo workload, could be everything for ("aaaaa" .. "bbbbb") { $gna = uc $_; } exit; } else { sleep 1; $run++; print "\n$run\n"; } }