/dev/tty does not work from shell
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue Feb 10 18:26:00 GMT 2015
On Feb 10 10:34, Eric Blake wrote:
> On 02/10/2015 09:46 AM, Helmut Karlowski wrote:
> >> The same test from the command line:
> >>
> >> $ stat -c %i /dev/tty - 0>/dev/tty
> >> 327680
> >> 8912896
> >>
> >> use any other (already-existing) file to see that the two numbers should
> >> normally be the same.
> >
> > Don't know why, but cygwin is not the only OS that does that. I'd
> > suggest to check for terminal or something.
>
> Umm, what other OS changes the inode from what you called stat() on to
> what you open()d? Okay, there are some special device files like
> /dev/ptmx that intentionally create a new device (and therefore new
> inode) every time it is opened, but is /dev/tty in that boat? POSIX
> requires /dev/tty to resolve to the process's controlling terminal.
>
> If there _are_ other OS that change the inode of the fd returned by
> opening /dev/tty, that argues that any change in bash to special-case
> /dev/tty should be made upstream, so I'm reluctant to write a
> cygwin-specific bash patch. If there aren't other OS that change the
> inode of /dev/tty, then it's better to figure out how to patch
> cygwin1.dll to be more like Linux.
That's that. The other is that the way /dev/tty works on Linux and
Cygwin is different. On Linux you open /dev/tty and the kernel
redirects all calls to the descriptor to your current controlling tty.
On Cygwin you open /dev/tty and the open call itself is redirected to
an open call of your current ctty. That doesn't naturally mean that
the stat/fstat inode numbers must be different, but they are right now
due to the underlying behaviour.
Whatever POSIX has to say about /dev/tty, I don't think this really
qualifies as a bug. There are apparently just a couple of ingrained
expectations floating around...
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Maintainer cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20150210/9748faac/attachment.sig>
More information about the Cygwin
mailing list