[Bug libc/5998] New: fwrite returns -1 and errno EINTR instead of a short write when sigaction without SA_RESTART is used
zlynx at acm dot org
sourceware-bugzilla@sourceware.org
Sun Mar 30 03:22:00 GMT 2008
I first ran into this in a C++ program. The program was using a periodic timer
without setting SA_RESTART in the sigaction call.
The result in the C++ program was that entire blocks of output to std::cout
would vanish because it never checks the return value of fwrite.
Then I tested with a C program and fwrite. I discovered that it returns -1 and
EINTR after the write syscall gets interrupted. So even if libstdc++ wanted to
check its return value, there is nothing useful there!
>From fwrite's man-page I'd expect it to return the number of items written, or
detect the EINTR and retry.
C++'s file stream operations do check for short writes and retry, I noticed.
But not the cout and cerr objects!
I believe fwrite's current implementation is not optimal. Sure, the C language
definition of which fwrite is a part does not know about signals, but that's no
reason to be sloppy.
--
Summary: fwrite returns -1 and errno EINTR instead of a short
write when sigaction without SA_RESTART is used
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: zlynx at acm dot org
CC: glibc-bugs at sources dot redhat dot com
GCC host triplet: x86_64-pc-linux-gnu
http://sourceware.org/bugzilla/show_bug.cgi?id=5998
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the Glibc-bugs
mailing list