[240] in Kerberos

home help back first fref pref prev next nref lref last post

Re: reporting of errors.

daemon@TELECOM.MIT.EDU (Bill Sommerfeld)
Thu Oct 29 15:59:34 1987

From: Bill Sommerfeld <wesommer@ATHENA.MIT.EDU>
To: kerberos@ATHENA.MIT.EDU

\begin{flame}
'errno' is a crock which people keep copying it in the vain hope that
they are calling something reasonable.

Global variables shared between libraries and applications are
inherently _evil_, since they clutter up the namespace.  In addition,
there are insufficient constraints on when errno can and cannot be
clobbered.  Instead, use of Ken's com_err package (which is already in
use by SMS, as well as being in use inside discuss and a few other
places) seems to make a lot of sense.

In the presence of 
\end{flame}

Exercise for the reader: 

/* 
 * Explain why this program prints "open: Not a typewriter" when it is
 * run with stdout redirected into a file.  The "printf" works fine, by
 * the way.
 *
 * Hints:  errno, "man 4 tty".  
 */

main()
{
	int fd;

	fd = open("/sadf/asdf/asdf/asd", 0, 0);

	if (fd == -1) {
		printf("Couldn't open the file\n");
		perror("open");
	}
	exit(0);
}

					- Bill




home help back first fref pref prev next nref lref last post