/dev/fd/N not synonymous with file descriptor N; it is on Linux

Houder houder@xs4all.nl
Mon Dec 17 04:30:00 GMT 2018


On 2018-12-16 22:55, Corinna Vinschen wrote:
[snip]

> I'm mulling over adding some hack to open().  It could try to recognize
> the special case of opening a processes' own descriptor symlink within
> /proc and then warp the open() call into dup().  No idea how tricky
> or even feasible that is, though...

That is why I wrote the following in my STC:

         // Q: does Cygwin attempt to read the /tmp directory? (an 
attempt that
         //    will fail, because the file has been unlinked)
         // it appears that reading a symlnk in /dev/fd can best be 
diverted to
         // the open file descriptor of the process ...

What I meant was, that I see no reason to modify the symlink in this
special case, but in stead of that to access the file using fd N, where
N is equal to the one in /dev/fd/N.

File descriptor N has been left open by bash and should not have been
closed as result of the exec ...

And indeed, I have _no_ clue if the above is feasible (and tricky?) in
Cygwin; otherwise I would have posted a solution.

Regards,
Henri

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple



More information about the Cygwin mailing list