From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3862 invoked by alias); 26 Jul 2008 20:47:48 -0000 Received: (qmail 3781 invoked by uid 48); 26 Jul 2008 20:47:06 -0000 Date: Sat, 26 Jul 2008 20:47:00 -0000 From: "l at lwithers dot me dot uk" To: glibc-bugs@sources.redhat.com Message-ID: <20080726204705.6771.l@lwithers.me.uk> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/6771] New: %m specifier in dprintf doesn't work as errno clobbered before output 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: 2008-07/txt/msg00118.txt.bz2 Using the "%m" (error string) specifier in dprintf() does not work when the file descriptor is non-seekable. lseek() is called on the file descriptor and sets errno to ESPIPE. Then it appears the actual formatting and outputting is done. This causes the %m in the output to always report "Illegal seek". I attach a simple test program which illustrates the problem. An excerpt of the strace output from this program illuminates the problem: unlink("nonexistent") = -1 ENOENT (No such file or directory) fstat(2, {st_mode=S_IFCHR|0600, st_rdev=makedev(136, 10), ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8edefb8000 lseek(2, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek) write(2, "Error: Illegal seek\n", 20) = 20 The expected behaviour would be for the original value of errno to be restarted after the lseek(), so that %m would output (in this case) "No such file or directory". I am using what Gentoo refer to as "2.8_p20080602". -- Summary: %m specifier in dprintf doesn't work as errno clobbered before output Product: glibc Version: unspecified Status: NEW Severity: normal Priority: P2 Component: libc AssignedTo: drepper at redhat dot com ReportedBy: l at lwithers dot me dot uk CC: glibc-bugs at sources dot redhat dot com http://sourceware.org/bugzilla/show_bug.cgi?id=6771 ------- You are receiving this mail because: ------- You are on the CC list for the bug, or are watching someone who is.