![]() |
|
P is for Practical | |
PerlMonks |
Re: Forks, Pipes and Exec (file descriptors)by almut (Canon) |
on Oct 29, 2008 at 23:14 UTC ( #720360=note: print w/replies, xml ) | Need Help?? |
The problem presumably is the following: the way you're connecting STDOUT to the pipe is changing the file descriptor number so that it's no longer 1. However, file descriptor 1 is what your exec'ed child process is assuming to be stdout (i.e. the default).
prints
Note that fileno changed from 1 to 6. In other words, you now have fileno 6 connected to the pipe (something an exec'ed child would know nothing about...) Something like this might work better
because this way, STDOUT keeps being associated with file descriptor 1:
Update: a simple demo:
In Section
Seekers of Perl Wisdom
|
|