MediaTracker has asked for the wisdom of the Perl Monks concerning the following question:
I'd like to create two child processes, pipe the first one's STDOUT into the second one's STDIN, and read the first one's STDERR. After reading the pipe manpage and perlipc I came up with this (broken) piece of code :
my ($READ, $WRITE); pipe ($READ, $WRITE); my $child1 = fork (); unless ($child1) { *STDOUT = $WRITE; exec ('cat', $0); } my $child2 = fork (); unless ($child2) { *STDIN = $READ; exec ('grep', 'grep'); } waitpid ($child1, 0); waitpid ($child2, 0);
I think my error is in the assignments to STDIN and STDOUT. I don't fully understand globs, so what you see here is mainly guesswork. I think what I need is some sort of equivalement to the C system call dup2. Any thoughts?
thank you for your time
MT
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Pipe two child processes
by Limbic~Region (Chancellor) on Aug 30, 2003 at 14:44 UTC | |
|
Re: Pipe two child processes
by hawtin (Prior) on Aug 31, 2003 at 09:51 UTC |