Xref: utzoo comp.unix.programmer:625 comp.unix.internals:1216 Path: utzoo!attcan!uunet!convex!convex.com!tchrist From: tchrist@convex.com (Tom Christiansen) Newsgroups: comp.unix.programmer,comp.unix.internals Subject: filters Keywords: stdout filters flush error exit Message-ID: <109685@convex.convex.com> Date: 2 Dec 90 01:00:15 GMT Sender: usenet@convex.com Reply-To: tchrist@convex.com (Tom Christiansen) Followup-To: comp.unix.programmer Organization: Convex Computer Corp, Richardson, TX Lines: 22 There seem to be a lot of filters out there that don't check that their output succeeded and blindly exit with success irrespective of the success of their writes. Cat and col are two utilities I've just caught doing this. Cat does make a stab at detecting this, but it does it wrong. It just checks ferror(stdout), but it's never done an fflush() or an fclose() first. Plus it only says "output write error", not what the error is. My first question I have is what could possible break if cat were to do an fclose(stdout) at the end (and check the status and set the exit accordingly). (We know it really needs the fclose and not just fflush because of the recent EDQUOTA debate, right?) My second question is whether this is just a symptom of sloppy programming or whether there's some reason why filters (mis)behave this way. thanks, --tom