Not a typewriter

chris at umcp-cs.UUCP chris at umcp-cs.UUCP
Mon Jun 16 07:23:05 AEST 1986


In article <542 at codas.ATT.UUCP> mikel at codas.ATT.UUCP (Mikel Manitius) writes:
>I think there may be one or two system calls that will alter
>errno to be 25, without returning a non-zero value, when in
>fact there was no error.

There are many library routines that may alter errno without in
fact failing; but there are no system calls that will do so.  This
is really the main distinction between manual sections 2 and 3,
as far as user code is concerned.

Incidentally, this points up a problem even with `good' error
handling routines.  I tend to write, e.g.,

	if ((fp = fopen(name, "w")) == NULL)
		error(1, errno, "cannot open %s for writing", name);

which usually results in a message like this:

	snerfle: cannot open breuglitz for writing: Permission denied

However, if the open failure were due to, say, running out of stdio
descriptors (but NOT file descriptors), it might say something wildly
inappropriate:

	snerfle: cannot open breuglitz for writing: Not a directory

My own opinion is that section 3 routines should set errno on errors
too.  (Actually, I think that `errno' itself should go away, but I
have no good replacement for it.)
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 1516)
UUCP:	seismo!umcp-cs!chris
CSNet:	chris at umcp-cs		ARPA:	chris at mimsy.umd.edu



More information about the Comp.unix mailing list