friendly messages

Chris Torek chris at mimsy.UUCP
Thu Mar 30 14:16:50 AEST 1989


In article <1411 at moscom.UUCP> jgp at moscom.UUCP (Jim Prescott) writes:
[much deleted; these are retained in order]
>	ret = vsprintf(buf, fmt, ap);
>	fprintf(stderr, "%s: %s", Progname, buf);
>		perror("");

Beware, beware!  His flashing eyes, his floating exception!

Oops, a bit of stream of unconsciousness there.

This can produce the infamous sendmail-style message:

	Cannot exec /bin/mail: Not a typewriter

because fprintf() can call isatty() which can set errno to ENOTTY.
To fix this you should either save and restore errno, or change the
code to fish the error message directly out of sys_errmsg[], or
use strerror() (if your C library has it).
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.unix.wizards mailing list