At 9:52 PM -0700 7/15/99, Matthew Dillon wrote: >:> ... How many programmers bother to even *clear* errno before >:> making these calls (since some system calls do not set errno >: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ >:> if it already non-zero). Virtually nobody. >: ^^^^^^^^^^^^^^^^^^^^^^^ >: >:Erm... WTF?!?! If so, why the HELL are we doing that?!? > > No, wait, I got that wrong I think. > > Oh yah, I remember now. Hmm. How odd. I came across a case > where read() could return -1 and not set errno properly if > errno was already set, but a perusal of the kernel code seems > to indicate that this can't happen. Very weird.
For what it's worth, I know I've run into situations where errno had to be cleared before calling some system routine (but I don't think it was read, and I am sure it wasn't on freebsd). As I remember it, it was some case where "sysrtn1" called another system routine (and you would be calling "sysrtn1"). If the call to the inner system routine failed, then the inner routine would set errno and "sysrtn" would return it's own error. However, "sysrtn1" would return the SAME error in some other circumstances, circumstances which did not set errno. So, if you wanted to check errno when you got an error return from "sysrtn1", you had to be sure to zero it out before calling "sysrtn1". This was a lesson taught after a long wild-goose chase trying to track down the wrong reason for an error-return from "sysrtn1" (whatever that routine was...), because we had NOT zeroed out errno first. --- Garance Alistair Drosehn = g...@eclipse.acs.rpi.edu Senior Systems Programmer or dro...@rpi.edu Rensselaer Polytechnic Institute To Unsubscribe: send mail to majord...@freebsd.org with "unsubscribe freebsd-hackers" in the body of the message