From owner-freebsd-hackers Fri Jun 23 9:12:19 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from bedrock.hboc.com (hboc.com [139.177.224.128]) by hub.freebsd.org (Postfix) with SMTP id 1D91337BAA0 for ; Fri, 23 Jun 2000 09:12:16 -0700 (PDT) (envelope-from Peter.Bohne@hboc.com) Received: from moosehead.hboc.com by bedrock.hboc.com via smtpd (for hub.FreeBSD.ORG [204.216.27.18]) with SMTP; 23 Jun 2000 16:12:16 UT Received: from SMTP (msteal.hboc.com [192.168.0.19]) by mrcheatem.hboc.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2448.0) id KJGFD0XK; Fri, 23 Jun 2000 12:11:02 +0100 Received: from dmz.hboc.com ([139.177.6.114]) by 192.168.0.19 (Norton AntiVirus for Internet Email Gateways 1.0) ; Fri, 23 Jun 2000 16:13:31 0000 (GMT) Received: from atlexc90nthub.hboc.com by dmz.hboc.com via smtpd (for wildgoose.hboc.com [192.168.0.19]) with SMTP; 23 Jun 2000 16:12:13 UT Received: by atlexc90nthub.hboc.com with Internet Mail Service (5.5.2448.0) id ; Fri, 23 Jun 2000 12:11:39 -0400 Message-ID: <35BEC7ED0A15D21199F000805F6F6D6A01CB00E2@bldexc01ntms.clinicom.com> From: "Bohne, Peter" To: "'andrew@ugh.net.au'" , "Bohne, Peter" Cc: FengYue , hackers@FreeBSD.ORG Subject: RE: libc_r/_read(), should the errno be reset to 0? Date: Fri, 23 Jun 2000 12:11:50 -0400 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2448.0) Content-Type: text/plain; charset="iso-8859-1" Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG Anytime you make a call that can potentially set errno, and you are planning to *check* errno afterwards, you have to set errno to 0 yourself. Once a system call sets errno to some (any) value, errno will just retain that value until the next system call that fails and sets errno. AFAIK *nothing* sets errno to 0, ever. (Except probably when your process first starts - errno probably gets initialized to 0, altho I don't even count on that. Someone else on the list may know about this.) *Always* set errno to 0 before you do your call if you want to inspect the value of errno after the call. I don't have the original post in front of me, but wasn't the problem that you wanted to check errno after a 2nd read() that had succeeded? If so, then errno will still have EAGAIN in it if the 1st read() had put it there, even tho the 2nd read succeeded. Maybe *I'm* the one missing something ... :-) pete > -----Original Message----- > From: andrew@ugh.net.au [mailto:andrew@ugh.net.au] > Sent: Friday, June 23, 2000 9:49 AM > To: Bohne, Peter > Cc: FengYue; hackers@FreeBSD.ORG > Subject: RE: libc_r/_read(), should the errno be reset to 0? > > > > > On Fri, 23 Jun 2000, Bohne, Peter wrote: > > > This means that *you* should set errno to 0 just before you > do the read > > call. At this point, you no longer care what it had been before. > > Why set it at all? If read returns an error then it will set > it for you > and if read doesn't return an error it doesn't really matter whats in > errno. > > Am I missing something? > > Andrew > > > > To Unsubscribe: send mail to majordomo@FreeBSD.org > with "unsubscribe freebsd-hackers" in the body of the message > To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message