in reply to Re: Pipe, fork, exec and red-hot pokers.
in thread Pipe, fork, exec and red-hot pokers.
This may be a long shot, but *how* are you reading that output? are you using the diamond operator, or are you reading via select(IO::Select) + read/sysread ? It may not have anything to do with your problem at all, but who knows...
FWIW, something like the following works for me
# 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' ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Pipe, fork, exec and red-hot pokers.
by hagus (Monk) on Apr 09, 2002 at 00:49 UTC |