On Fri, Dec 12, 2008 at 05:36:36PM -0600, Nicolas Williams wrote: > So, yes, open(2) of /dev/fd/N is as a dup(2) of N.
Also, every reference I can find says that open(2) of /dev/fd/N is supposed to be a dup(2) of file descriptor N, on Solaris, on Linux, on BSD, on Plan 9. And, apparently also the convention is that open(2) of /proc/self/fd/N is NOT equivalent to dup(2) of fd N (it opens the same file, device, whatever, but does not keep the offset from fildes N). % (read line <#((200)) ; print $line ; read line </proc/self/fd/9 ; print $line) <&9 1041 1001 % And that's supposed to be so for Linux and Solaris (haven't checked BSD). An open(2) of /proc/self/fd/N is supposed to check file permissions too: % pfexec chown root /tmp/foo % pfexec chmod 600 /tmp/foo % (read line <#((200)) ; print $line ; read line </proc/self/fd/9 ; print $line) <&9 1041 ksh93: /proc/self/fd/9: cannot open [Permission denied] 1041 % Nico --