ewheeler has asked for the wisdom of the Perl Monks concerning the following question:
We are trying to open a file descriptor and access it from a forked + exec child. It works in bash as follows:
# exec 3< /etc/passwd # grep root /proc/self/fd/3 root:x:0:0:root:/root:/bin/bash
When we test with perl using the code below, grep complains about fd/3 not existing.
open(my $in, '/etc/passwd'); if (!fork()) { exec("grep", "root", "/proc/self/fd/" . fileno($in)); } close($in);
What am I missing, is fork or exec closing the leaked file descriptor?
-Eric
|
|---|