Mail Archives: djgpp-workers/2000/08/31/14:14:04
On Thu, 31 Aug 2000 09:51:46 +0200, you wrote:
> > It's not sufficient to simply test errno to see if an error occured,
> > because it only has meaningful value if tested after a system call
> > that has returned some failure indication.
>
> And if I have not missing anything, this is the only way bail() will be
> used - right after failed syscall.
bail() will be called due to fseek outside file boundary, or fread
past eof; these are not failed system calls. If you know these
functions will always set errno=0 (no POSIX function is required to do
that) then your code would be safe.
In that case, the only change I would make would be to rename it
bail_syserr(), or something like that, to be clearer about its
purpose, and to add some comment warning that it probably won't work
outside of djgpp.
> If you don't change your mind about errno, then I'll commit current bail()
> version. It's code of yours, after all.
Sure it's my code. I have no problem, though, if you want to improve
it with inside knowledge of how djgpp implements errno. Perhaps you
could mail the patch first, I'll re-run the tests I did, then you can
commit it.
> > There is some generic
> > code by Richard Stevens which takes printf style arguments to provide
> > better context to the error reporting, I can dig this out if you like.
>
> Yes, I'm curious.
There are 5 functions for putting error messages to stderr:
err_ret(): Nonfatal error related to a system call.
Print a message and return.
err_sys(): Fatal error related to a system call.
Print a message and terminate.
err_dump(): Fatal error related to a system call.
Print a message, dump core, and terminate.
err_msg(): Nonfatal error unrelated to a system call.
Print a message and return.
err_quit(): Fatal error unrelated to a system call.
Print a message and terminate.
The code is in apue/advio/ourhdr.h and apue/lib.44/error.c, from the
archive http://www.kohala.com/start/apue.tar.Z
No changes are required to compile with DJGPP,
just #include "ourhdr.h" and link with error.c.
--
[please cc all replies, thanks]
- Raw text -