On 02/09/2015 01:53 PM, Eric Blake wrote: > On 02/09/2015 01:38 PM, Thomas Wolff wrote: > >>> 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’t apply to device files (and doesn’t on other >> systems) - >> man bash: “redirection will fail if the file ... is a regular file.” > > 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 = open("/dev/tty", O_CREAT|O_WRONLY, 0666); if (fd < 0) return 2; if (fstat(fd, &st2)) return 3; printf ("%lld %c= %lld\n", (long long) st1.st_ino, st1.st_ino == st2.st_ino ? '=' : '!', (long long) st2.st_ino); return 0; } -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature