if ( ! defined($kidpid = fork() ) ) { # fork returned undef, so failed die "Cannot fork: $!"; } elsif ($pid == 0) { # fork returned 0, so this branch is child # want to tun program like this: ( time exe < stdin > stdout ) >&! stdlog exec( code to run program goes here.... ); # if exec fails, fall through to the next statement die "can't exec date: $!"; } else { # fork returned 0 nor undef so this branch is parent # run-time monitoring code goes here.... waitpid($kidpid, 0); }