From owner-freebsd-current Thu Jun 18 21:01:44 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id VAA15319 for freebsd-current-outgoing; Thu, 18 Jun 1998 21:01:44 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from mail.camalott.com (root@mail.camalott.com [208.203.140.2]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id VAA15300 for ; Thu, 18 Jun 1998 21:01:34 -0700 (PDT) (envelope-from joelh@gnu.org) Received: from detlev.UUCP (tex-130.camalott.com [208.229.74.130] (may be forged)) by mail.camalott.com (8.8.7/8.8.5) with ESMTP id XAA01082; Thu, 18 Jun 1998 23:01:02 -0500 Received: (from joelh@localhost) by detlev.UUCP (8.8.8/8.8.8) id XAA07310; Thu, 18 Jun 1998 23:01:30 -0500 (CDT) (envelope-from joelh) Date: Thu, 18 Jun 1998 23:01:30 -0500 (CDT) Message-Id: <199806190401.XAA07310@detlev.UUCP> To: richard@cogsci.ed.ac.uk CC: imp@village.org, tlambert@primenet.com, current@FreeBSD.ORG In-reply-to: <22587.199806172313@cockburn.cogsci.ed.ac.uk> (message from Richard Tobin on Thu, 18 Jun 1998 00:13:05 +0100) Subject: Re: Bogus errno twiddling by lstat... From: Joel Ray Holveck Reply-to: joelh@gnu.org References: <22587.199806172313@cockburn.cogsci.ed.ac.uk> Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >> No. When a system call returns success, the value of errno is >> undefined. > No! A successful system call leaves it *unchanged*. From intro(2): >> Successful calls never set errno; once set, it remains >> until another error occurs. You are technically correct-- but this is not relevant to Jordan's issue, because of the distinction between system calls and library routines. You quoted the intro to system calls. In Jordan's example, there was an error in a system call (specifically, open("/etc/malloc.conf",...))-- but it is handled by the printf() library routine. > I believe ANSI C has a similar requirement. Rather the opposite. ISO C requires that nothing set errno to zero, but may fiddle with it all they want otherwise. (I haven't examined the ANSI spec on the issue, but it is similar if not identical.) > You should only examine errno after an error, but you are allowed to > have had intervening successful system calls. Yes, but there was a failed system call (specifically, open("/etc/malloc.conf", ...)) intervening. Happy hacking, joelh -- Joel Ray Holveck - joelh@gnu.org - http://www.wp.com/piquan Fourth law of programming: Anything that can go wrong wi sendmail: segmentation violation - core dumped To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message