# note: this code will go into infinite loop # and is not a particularly good piece of code... use IO::Handle; use IO::Select; my( $readfh, $writefh ) = ( IO::Handle->new(), IO::Handle->new() ); pipe( $readfh, $writefh ); if( my $pid = fork() ) { $writefh->close(); my $select = IO::Select->new( $readfh ); my $buf; while( 1 ) { if( $select->can_read( 1 ) ) { if( read( $readfh, $buf, 4096, 0 ) ) { print "got '$buf'"; } } } } else { $readfh->close; open( STDOUT, sprintf( '>&%d', $writefh->fileno ) ); STDOUT->autoflush(1); exec( 'find', '/usr/local/lib/perl5' ); }