lint question

Peter da Silva peter at ficc.uu.net
Wed Jan 11 00:46:39 AEST 1989


In article <9322 at smoke.BRL.MIL>, gwyn at smoke.BRL.MIL (Doug Gwyn ) writes:
> The one possible exception is
> 	(void)fprintf(stderr, "...: operation failed\n");
> because if a write to the standard error output fails, you may have just
> exhausted your error-recovery resources and can do no better anyway.
> (What are you going to do, complain about THAT failure on stderr?)

	if(fprintf(stderr, "...: operation failed\n") == FAIL) {
		if(!(fp = fopen("/dev/tty", "w"))) {
			if(!(fp = fopen("/dev/console", "w"))) {
				chdir("/tmp");
				abort();
			}
		}
		(void)fprintf(fp, "...: operation failed\n");
		fclose(fp);
	}

And to be totally safe, use open()...

Not entirely smiley. There are programs that don't have 0, 1, and 2 open
for lengths of time. Like, a modem callback program...
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.
Work: uunet.uu.net!ficc!peter, peter at ficc.uu.net, +1 713 274 5180.   `-_-'
Home: bigtex!texbell!sugar!peter, peter at sugar.uu.net.                 'U`
Opinions may not represent the policies of FICC or the Xenix Support group.



More information about the Comp.lang.c mailing list