From owner-freebsd-current Wed Jun 17 12:51:10 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id MAA23433 for freebsd-current-outgoing; Wed, 17 Jun 1998 12:51:10 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from smtp03.primenet.com (daemon@smtp03.primenet.com [206.165.6.133]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id MAA23413 for ; Wed, 17 Jun 1998 12:51:00 -0700 (PDT) (envelope-from tlambert@usr01.primenet.com) Received: (from daemon@localhost) by smtp03.primenet.com (8.8.8/8.8.8) id MAA03780; Wed, 17 Jun 1998 12:50:50 -0700 (MST) Received: from usr01.primenet.com(206.165.6.201) via SMTP by smtp03.primenet.com, id smtpd003713; Wed Jun 17 12:50:39 1998 Received: (from tlambert@localhost) by usr01.primenet.com (8.8.5/8.8.5) id MAA25326; Wed, 17 Jun 1998 12:50:36 -0700 (MST) From: Terry Lambert Message-Id: <199806171950.MAA25326@usr01.primenet.com> Subject: Re: Bogus errno twiddling by lstat... To: peter@netplex.com.au (Peter Wemm) Date: Wed, 17 Jun 1998 19:50:35 +0000 (GMT) Cc: tlambert@primenet.com, current@FreeBSD.ORG In-Reply-To: <199806170032.IAA06067@spinner.netplex.com.au> from "Peter Wemm" at Jun 17, 98 08:32:56 am X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 1: This is a classic programming error.. You're not really supposed to be > looking at the value of errno except right after a -1 return from > something. I know I'm not supposed to be. However, it's not supposed to be diddling the errno. > 2: the no such file or directory is actually stdio calling malloc, which > is doing a readlink on /etc/malloc.conf, which probably doesn't exist. I knew that it was malloc, though I hadn't bothered to find out why. The malloc.conf access is triggered in the ld.so. It should *not* be retriggered in stdio, in any case (ie: the malloc code should be caching the return values). > 3: You're calling stdio (ie: printf) *after* lstat() so you've gotten > what's coming to you. :-) You're initializing the entire stdio system > after calling lseek(). It's stdio that's leaking the errno. This is irrlevent, since the printf did not fail. The errno is not supposed to be manipulated across a non-failing system call, nor across anon-failing library routine which pretends to be atomic (per ANSI requirements for stdio/stdlib/etc.). Anyway, I wasn't relying on it, that was just the minimal case that replicated the error. The perror() with errno == 0 is supposed to print out the "No error" message (else why have it there?). Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message