Article View: comp.bugs.sys5
Article #1157Digression: use of perror() (Re: High speed serial I/O under system load)
From: Peter da Silva
Date: Thu, 18 Jul 1991 14:06
Date: Thu, 18 Jul 1991 14:06
16 lines
2097 bytes
2097 bytes
Please respect followups. This digression has nothing to do with write()
problems (though I suspect an interrupted system call).
In article <1991Jul17.174348.24529@world.std.com> jaa@world.std.com (Jerry A Abramson) writes:
> fprintf(stderr,"\n\rvtko: Write Failure\n\r");
> perror("vtko");
Suggestion: put the perror() before the fprintf(). It is possible for fprintf
to clobber errno, guaranteeing a bogus response.
Alternative: save errno before the fprintf and restore it afterwards.
Moral: never call perror() except immediately after a failed system call.
--
Peter da Silva; Ferranti International Controls Corporation; +1 713 274 5180;
Sugar Land, TX 77487-5012; `-_-' "Have you hugged your wolf, today?"
Technical Details
Message-ID:
<QBPCR92@xds13.ferranti.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!wotan!moxie!sugar!ficc!peterReferences:
<wd.678549611@distel> <1991Jul17.174348.24529@world.std.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f8c9b,dcdeb9f09654f086 X-Google-Attributes: gidf8c9b,public X-Google-Thread: 1048e3,dcdeb9f09654f086 X-Google-Attributes: gid1048e3,public X-Google-Thread: fc89c,c2843e9cb6b55ed5,start X-Google-Attributes: gidfc89c,public X-Google-Thread: f7cee,dcdeb9f09654f086 X-Google-Attributes: gidf7cee,public X-Google-Thread: 10650a,dcdeb9f09654f086 X-Google-Attributes: gid10650a,public X-Google-Thread: 1014db,c2843e9cb6b55ed5,start X-Google-Attributes: gid1014db,public X-Google-Thread: 134180,ddc7ffeb02f47231 X-Google-Attributes: gid134180,public X-Google-ArrivalTime: 1991-07-18 12:13:16 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!cs.utexas.edu!wotan!moxie!sugar!ficc!peter From: peter@ficc.ferranti.com (Peter da Silva) Newsgroups: comp.bugs.sys5,comp.unix.internals,comp.unix.questions,comp.unix.sysv386,biz.sco.opendesktop,comp.lang.c,comp.unix.programmer Subject: Digression: use of perror() (Re: High speed serial I/O under system load) Keywords: SVR3, i386, tty, flow control Message-ID: <QBPCR92@xds13.ferranti.com> Date: 18 Jul 91 14:06:52 GMT References: <wd.678549611@distel> <1991Jul17.174348.24529@world.std.com> Reply-To: peter@ficc.ferranti.com (Peter da Silva) Followup-To: comp.lang.c,comp.unix.programmer Organization: Xenix Support, FICC Lines: 16