This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/11161] New: process with closed fd 2 sees no problem on stdout
- From: "kogorman at calpoly dot edu" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sources dot redhat dot com
- Date: 12 Jan 2010 19:44:54 -0000
- Subject: [Bug libc/11161] New: process with closed fd 2 sees no problem on stdout
- Reply-to: sourceware-bugzilla at sourceware dot org
When a process is started with file descriptor 2 closed (such as some daemon
processes, or for headless operation), or if fd 2 becomes closed without
explicitly closing stdout, functions on filestream stdout do not report errors.
I will attach a C program that illustrates this situation.
Run it from bash as "fsbad >&-" to start with a closed STDOUT_FILENO.
I know that processes which expect fd2 to be closed should not be writing to
stdout, but it seems odd for the error not to be reported. What is even more
odd is that the first attempt to use stdout changes 'errno' to EBADF, but
otherwise gives a normal return.
This was a problem for me because I am teaching systems programming, and I tell
my students to get in the habit of checking all calls for errors, and they hit
on this as a technique to test their code, and thoght they had done something wrong.
--
Summary: process with closed fd 2 sees no problem on stdout
Product: glibc
Version: 2.8
Status: NEW
Severity: normal
Priority: P2
Component: libc
AssignedTo: drepper at redhat dot com
ReportedBy: kogorman at calpoly dot edu
CC: glibc-bugs at sources dot redhat dot com,kogorman at
calpoly dot edu
http://sourceware.org/bugzilla/show_bug.cgi?id=11161
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.