Re: errno

From: Philippe Troin
Date: Tue May 04 2004 - 01:01:34 EST


Linus Torvalds <torvalds@xxxxxxxx> writes:

> On Mon, 3 May 2004, Albert Cahalan wrote:
> >
> > The obvious fix would be to stuff errno into the
> > task_struct, hmmm?
>
> No. "errno" is one of those fundamentally broken things that should not
> exist. It was wrogn in original UNIX, it's wrong now.
>
> The kernel usage comes not from the kernel wanting to use it per se (the
> kernel has always used the "negative error" approach), but from some
> misguided kernel modules using the user-space interfaces.
>
> The Linux way of returning negative error numbers is much nicer. It's
> inherently thread-safe, and it has no performance downsides. Of course, it
> does depend on having enough of a result domain that you can always
> separate error returns from good returns, but that's true in practice for
> all system calls.

Except of course for fcntl(fd, F_GETOWN) where the owner is a
(negative) process group... If the owning process group has a "low
enough" PGID, it collides with errors and glibc reports an error and
sets errno to -PGID. One might argue that in this instance, that the
BSD's overloading of the pid field with pgids is at fault, but the bug
still remains :-)

Phil.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/