/dev/tty does not work from shell

Eric Blake eblake@redhat.com
Tue Feb 10 17:34:00 GMT 2015

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.

Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20150210/331d2b73/attachment.sig>

More information about the Cygwin mailing list