[PATCH] libc_r bug: successful close(2) sets errno to ENOTTY
Terry Lambert
tlambert2 at mindspring.com
Tue Nov 25 18:53:19 PST 2003
Stefan Farfeleder wrote:
> On Mon, Nov 24, 2003 at 07:05:02PM +0100, boyd, rounin wrote:
> > From: "Jacques A. Vidrine" <nectar at FreeBSD.org>
> > > The application is broken. You must only check errno if you get an
> > > error indication from the library call.
> >
> > errno is only meaningful after a syscall error.
>
> Wrong, counter-example: strtol().
Wrong; the standard specifies that the errno shall only be
checked when the return value is -1. The exception in the
strtol() case is only for presetting errno to 0 before you
make the call, and making a check only following a -1 return.
You cannot make assumptions about underlying implementations;
they may be either system calls or library routines, and your
application is not supposed to know or depend on which case
prevails.
-- Terry
More information about the freebsd-current
mailing list