Path: utzoo!attcan!uunet!lll-winken!ames!nrl-cmf!ukma!cwjcc!gatech!rutgers!bellcore!texbell!sugar!ficc!peter From: peter@ficc.uu.net (Peter da Silva) Newsgroups: comp.lang.c Subject: Re: lint question Message-ID: <2679@ficc.uu.net> Date: 10 Jan 89 14:46:39 GMT References: <491@babbage.acc.virginia.edu> <9322@smoke.BRL.MIL> Organization: Xenix Support Lines: 27 In article <9322@smoke.BRL.MIL>, gwyn@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@ficc.uu.net, +1 713 274 5180. `-_-' Home: bigtex!texbell!sugar!peter, peter@sugar.uu.net. 'U` Opinions may not represent the policies of FICC or the Xenix Support group.