in reply to Problem with IPC::Open2 when STDOUT/STDERR are redirected
For the Nth time, don't use local to save/restore file handles, especially the STD* handles. Follow the example in the open documentation for saving and restoring file handles.
A subprocess will inherit and use file descriptors 0, 1, and 2 from the parent process. local *STDOUT; hides away file descriptor 1 and prevents the process from being able to change it (and prevents Perl from doing its normal extra work when STDOUT is re-opened such that file descriptor 1 would be used).
Update: s/file handle (\d)/file descriptor $1/g, etc.
- tye
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Problem with IPC::Open2 when STDOUT/STDERR are redirected (!local)
by Zaxo (Archbishop) on Feb 29, 2008 at 11:09 UTC | |
by tye (Sage) on Feb 29, 2008 at 15:41 UTC |