#!/usr/bin/perl -w exit 0 if (eof(STDIN)); pipe(IN,OUT); $pid=fork; if ($pid<0) { die "fork failed: $!\n"; } elsif ($pid>0) { close(IN); while () { print OUT; } close(OUT); wait; exit $?>>8; } else { close(OUT); open(STDIN, "<&IN"); exec @ARGV or die "exec failed: $!\n"; }