/dev/fd/N not synonymous with file descriptor N; it is on Linux
Tue Jan 22 10:20:00 GMT 2019
On Tue, 22 Jan 2019 10:41:57, Corinna Vinschen wrote:
> On Jan 22 10:25, Houder wrote:
> > Curious! It fails (for me) on W7 ...
> It works for me just as well on W7:
> $ uname -a
> CYGWIN_NT-6.1 vmbert764 2.12.0(0.333/5/3) 2019-01-21 22:47 x86_64 Cygwin
> $ ./stca /dev/fd/0 <<EOF
> ? bla
> ? EOF
> fd1 =3D 0
> argv =3D /dev/fd/0
> fd2 =3D 3
> buf =3D \
> Hello, world!
That is odd ... (I am using the same version of Cygwin as you do, do I
64-@@ uname -a
CYGWIN_NT-6.1 Seven 2.12.0s(0.333/5/3) 2019-01-21 10:25 x86_64 Cygwin
(however, I only replaced the cygwin1.dll)
(the snapshot is apparently not the same as your version 2.12.0)
> > > Not sure what you're testing.
> > STC inherits a "read-only" open file descriptor from bash. On Linux
> > the file can be opened read-write (via procfs), because a new entry
> > is created in the open file table.
> > (opening the file read-write (via fdescfs) on FreeBSD would fail)
> > For this reason the output does not show what has been entered via
> > the here-doc.
> > In short, I was merely testing the semantics of Linux.
> Ah, ok. This is a bit of a problem on Windows. The code tries to
> reopen the file by handle. Under some circumstances(*) we can't reopen
> the file. In that case the code just tries to duplicate the handle.
> However, a duplicated file handle can't have more permissions than the
> original handle.
> So if it fails for you, it seems the reopen failed and the handle
> only got duplicated. In that case, you can't gain write perms if
> the original handle only got read perms.
> What the code fails to do is trying to open the file by name as a last
> resort. There was a (good?) reason I didn't implement that, but I don't
> remember ATM.
Not relevant in this case, as the file has been deleted ... (i.e., in this
case, it cannot be opened by name).
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin