No such thing as a small change | |
PerlMonks |
•Re: close STDOUT and system equal strange?by merlyn (Sage) |
on Feb 21, 2004 at 23:22 UTC ( [id://330862]=note: print w/replies, xml ) | Need Help?? |
You're trying to pull a fast one on the kernel, and you lost. "standard output" is file descriptor 1. When you open a new file, it goes to the lowest unopened file descriptor. Normally, 0, 1, and 2 are all busy being standard input/output/error, but by closing STDOUT, you left room for another file to be fd 1. Hence, you lose. If you don't want that behavior, don't do that.
If you want to ensure that the child's standard output goes nowhere, open STDOUT onto /dev/null instead. -- Randal L. Schwartz, Perl hacker
In Section
Seekers of Perl Wisdom
|
|