in reply to Leaking a file descriptor into a child to use with /proc/self/fd/3

And what do you expect to happen when you do:

exec 4< /etc/passwd; exec 5< /etc/passwd

I don't think a redirection is a 2-way thing ...

What about this?

open(my $in1, '</etc/passwd'); open(my $in2, '</etc/passwd');

Do you expect the OS to give you the same fd when (re-)opening a specific file?

btw,

if (!fork()) { system('ls -al /proc/self/fd/');}

shows that fd #3 is "linked" to /etc/passwd even for the child of the child of bash.

bw, bliako