Message189233
> I assume my glibc and fwrite aren't broken though
Actually, it's a glibc bug when the last character is a '\n':
$ python -c "f = open('/dev/full', 'w', 1); f.write('hello'); f.close()"
Traceback (most recent call last):
File "<string>", line 1, in <module>
IOError: [Errno 28] No space left on device
Normal.
Now, you add a trailing newline:
$ strace -e write python -c "f = open('/dev/full', 'w', 1); f.write('hello'); f.write('\n'); f.close()"
write(3, "hello\n", 6) = -1 ENOSPC (No space left on device)
write() still returns ENOSPC, but it gets ignored by fwrite().
I've had a quick look at the source, and I think the culprit is here:
http://sourceware.org/git/?p=glibc.git;a=blob;f=libio/fileops.c#l1270
1336 if (do_write)
1337 {
1338 count = new_do_write (f, s, do_write);
1339 to_do -= count;
1340 if (count < do_write)
1341 return n - to_do;
1342 }
It looks like there's a check missing here for count < 0. |
|
Date |
User |
Action |
Args |
2013-05-14 16:26:07 | neologix | set | recipients:
+ neologix, jasujm |
2013-05-14 16:26:07 | neologix | set | messageid: <1368548767.55.0.919021731763.issue17976@psf.upfronthosting.co.za> |
2013-05-14 16:26:07 | neologix | link | issue17976 messages |
2013-05-14 16:26:07 | neologix | create | |
|