$pid = fork(); $timeout = 3; if($pid) { local $SIG{ALRM} = sub { die "TIMEOUT" }; alarm $timeout; eval { waitpid( $pid, 0 ); }; alarm 0; if ( $@ && $@ =~ m/TIMEOUT/ ) { $output = ""; } } else { $output = qx("Encoder.exe -i test -o _test -t4 $t4 2>&1"); exit(0); }