www.delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:date:from:mime-version:to:subject | |
:references:in-reply-to:content-type; q=dns; s=default; b=V9hZ5M | |
J3dXLzMUZ//sDNZDmMD/bnj9aIfbJYuLn1iOyPd2mjZ7UQ02nVdRPLCmFBYN3IAX | |
/OZnxVBtfOa+FQbUFv12j11BIBU/hRjeMMlbFu8LTeRzIMkNr1seM5jXN3xfZdWt | |
6pWEWx3ZWnFEOOl0TSCgkAES260Vdtr8E/iXs= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:message-id:date:from:mime-version:to:subject | |
:references:in-reply-to:content-type; s=default; bh=OBhsNaiURi6D | |
u+rUL3HYpqmgBMM=; b=r+lkceAnG1X9lzODjnjdfB/xlQpkvcc2q8wxZU6I2BA0 | |
f8OwZDlMAsX2R2ijEm7a3tMm3aHe1uNxjrPYJRf7JCasZ3FQ+Yg6OSpg+5OJKTmv | |
7fTZZzDKYMxEpYbVfRQujERW7cs+qJKU/NEYo/nsjU8ryrtGcbpMu392yr5oczY= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.com> |
List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
List-Archive: | <http://sourceware.org/ml/cygwin/> |
List-Post: | <mailto:cygwin AT cygwin DOT com> |
List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
Sender: | cygwin-owner AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
Delivered-To: | mailing list cygwin AT cygwin DOT com |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-2.0 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 |
X-HELO: | mx1.redhat.com |
Message-ID: | <54DA31C1.9060406@redhat.com> |
Date: | Tue, 10 Feb 2015 09:28:49 -0700 |
From: | Eric Blake <eblake AT redhat DOT com> |
User-Agent: | Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
MIME-Version: | 1.0 |
To: | cygwin AT cygwin DOT com |
Subject: | Re: /dev/tty does not work from shell |
References: | <1598899839 DOT 20150209072327 AT yandex DOT ru> <54D8741A DOT 5020805 AT towo DOT net> <20150209113620 DOT F876DF38 DOT helmut DOT karlowski AT ish DOT de> <54D91AC6 DOT 8030101 AT towo DOT net> <54D91E53 DOT 5080907 AT redhat DOT com> |
In-Reply-To: | <54D91E53.5080907@redhat.com> |
OpenPGP: | url=http://people.redhat.com/eblake/eblake.gpg |
X-IsSubscribed: | yes |
--Ocf70oJiAw05vGJHnrkc8E0P87qJXk8PD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 02/09/2015 01:53 PM, Eric Blake wrote: > On 02/09/2015 01:38 PM, Thomas Wolff wrote: >=20 >>> bash prints that message when it has the noclobber-option set. Maybe >>> you check it? >> Yes, indeed, the effect shows up after set -o noclobber; >> however, this shouldn=E2=80=99t apply to device files (and doesn=E2=80= =99t on other >> systems) - >> man bash: =E2=80=9Credirection will fail if the file ... is a regular fi= le.=E2=80=9D >=20 > Huh. I can reproduce it, even with the new experimental bash 4.3. I'll > see if I can find the bug in the sources. The bug is in cygwin1.dll, not bash. Here's a STC; opening a file should NOT change its st_ino number, but that's exactly what cygwin is doing to /dev/tty. As such, bash thinks that because the ino changed between stat() and open() that there is a race of someone trying to do bad things behind bash's back, and noclobber restrictions kick in to prevent bash from using the file. #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <sys/stat.h> int main(void) { struct stat st1, st2; if (stat"/dev/tty", &st1)) return 1; int fd =3D open("/dev/tty", O_CREAT|O_WRONLY, 0666); if (fd < 0) return 2; if (fstat(fd, &st2)) return 3; printf ("%lld %c=3D %lld\n", (long long) st1.st_ino, st1.st_ino =3D=3D st2.st_ino ? '=3D' : '!', (long long) st2.st_ino); return 0; } --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --Ocf70oJiAw05vGJHnrkc8E0P87qJXk8PD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJU2jHBAAoJEKeha0olJ0NqH1MH/RaOMIBUvFTDIFdfqSY0mfMH fQf0koq19HOj3kq18qJo8JWj4RJy18kaU9zYc87aNbVv26aGydiYLIPbK3wzCEuk 0CRoCeQTUO2o3ZlGGyAYr/d8HX0IEALELuCOw+vagGCP1rsNIVHmSSQDSPrgo7tJ RRleqYPZvSA2E8WqqWJRjPWN7tX16Xbq2Nc1PVf60jk5elBPR143JzfnhRnuIHW/ ix/MfdBIaC0uwNBojlvruWgamsRMwSpO/fpSHeYscThy04nTLj8Uem7CDsbcXQyA HYLJv3HRE7bNH1eFc6meYcYY3UyxKSYLkXXzs2MUyY+6oCaCTGP3UM/mhcZlWyE= =5SKa -----END PGP SIGNATURE----- --Ocf70oJiAw05vGJHnrkc8E0P87qJXk8PD--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |