From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9938 invoked by alias); 12 Jan 2010 19:45:14 -0000 Received: (qmail 9556 invoked by uid 48); 12 Jan 2010 19:44:54 -0000 Date: Tue, 12 Jan 2010 19:45:00 -0000 From: "kogorman at calpoly dot edu" To: glibc-bugs@sources.redhat.com Message-ID: <20100112194453.11161.kogorman@calpoly.edu> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/11161] New: process with closed fd 2 sees no problem on stdout X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2010-01/txt/msg00036.txt.bz2 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.