my $chld_flag = 0; $SIG{'CHLD'} = sub { $chld_flag = 1; }; $SIG{'ALRM'} = 'IGNORE'; while (1) { # Check child processes # Includes using waidpid() to clean up after child processes # Display status # Get user commands my $cmd = ''; eval { # Allow interrupts by alarms and 'child' events local $SIG{'CHLD'} = sub { die("CHLD EVENT\n"); }; local $SIG{'ALRM'} = sub { die("ALRM EVENT\n"); }; alarm(10); if (! $chld_flag) { $cmd = ; } }; alarm(0); $chld_flag = 0; # Process user command, if any # Such as launch child processes }