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: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
> Sent: Friday, June 23, 2000 9:49 AM
> To: Bohne, Peter
> Cc: FengYue; [EMAIL PROTECTED]
> 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 [EMAIL PROTECTED]
> with "unsubscribe freebsd-hackers" in the body of the message
>
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message