public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/11161] New: process with closed fd 2 sees no problem on stdout
@ 2010-01-12 19:45 kogorman at calpoly dot edu
  2010-01-12 19:46 ` [Bug libc/11161] " kogorman at calpoly dot edu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: kogorman at calpoly dot edu @ 2010-01-12 19:45 UTC (permalink / raw)
  To: glibc-bugs

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.


^ permalink raw reply	[flat|nested] 5+ messages in thread
[parent not found: <bug-11161-131@http.sourceware.org/bugzilla/>]

end of thread, other threads:[~2014-06-30 20:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-12 19:45 [Bug libc/11161] New: process with closed fd 2 sees no problem on stdout kogorman at calpoly dot edu
2010-01-12 19:46 ` [Bug libc/11161] " kogorman at calpoly dot edu
2010-01-12 19:52 ` kogorman at calpoly dot edu
2010-01-15  8:00 ` drepper at redhat dot com
     [not found] <bug-11161-131@http.sourceware.org/bugzilla/>
2014-06-30 20:23 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).