From: Houder <houder@xs4all.nl>
To: cygwin@cygwin.com
Subject: Re: /dev/fd/N not synonymous with file descriptor N; it is on Linux
Date: Tue, 22 Jan 2019 10:20:00 -0000 [thread overview]
Message-ID: <45382f09a86b6cf3bcabd82adb593622@smtp-cloud8.xs4all.net> (raw)
In-Reply-To: <20190122094157.GN2802@calimero.vinschen.de>
On Tue, 22 Jan 2019 10:41:57, Corinna Vinschen wrote:
> On Jan 22 10:25, Houder wrote:
[snip]
> > 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[1] =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
not?)
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.
Understood.
> 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).
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
next prev parent reply other threads:[~2019-01-22 10:20 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-16 16:31 Houder
2018-12-16 20:28 ` Corinna Vinschen
2018-12-16 20:31 ` Corinna Vinschen
2018-12-16 21:36 ` Wayne Davison
2018-12-16 21:55 ` Corinna Vinschen
2018-12-17 4:30 ` Houder
2018-12-17 9:25 ` Corinna Vinschen
2018-12-17 11:26 ` Corinna Vinschen
2019-01-02 13:56 ` Houder
2018-12-17 3:41 ` Houder
2019-01-06 20:19 ` Corinna Vinschen
2019-01-22 8:50 ` Houder
2019-01-22 8:57 ` Houder
2019-01-22 9:06 ` Corinna Vinschen
2019-01-22 9:25 ` Houder
2019-01-22 9:42 ` Corinna Vinschen
2019-01-22 10:20 ` Houder [this message]
2019-01-22 10:39 ` Corinna Vinschen
2019-01-27 18:39 ` Houder
2019-01-27 21:57 ` Corinna Vinschen
2019-01-27 22:12 ` Corinna Vinschen
2019-01-28 14:15 ` Houder
2019-01-28 16:51 ` Corinna Vinschen
2019-01-22 9:02 ` Corinna Vinschen
2019-01-22 9:07 ` Corinna Vinschen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=45382f09a86b6cf3bcabd82adb593622@smtp-cloud8.xs4all.net \
--to=houder@xs4all.nl \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).