From mboxrd@z Thu Jan 1 00:00:00 1970 From: random832@fastmail.com (Random832) Date: Tue, 19 Sep 2017 14:09:06 -0400 Subject: [TUHS] Happy birthday, Dennis Ritchie! [ really sun vs dec/apollo --> X and NeWS ] In-Reply-To: <20170919122425.513E34422C@lignose.oclsc.org> References: <20170919122425.513E34422C@lignose.oclsc.org> Message-ID: <1505844546.1334583.1111457456.3BAC6336@webmail.messagingengine.com> On Tue, Sep 19, 2017, at 08:24, Norman Wilson wrote: > I guess the problem with perror is that it isn't sufficiently > UNIX-like: it bundles three jobs that are really separate > (convert errno to string message, format an error message, > output the message) into one function, inseparably and > inflexibly. Yeah, but you have to do all of that (plus exit, if the error isn't recoverable) after every single function that might fail. If the function didn't exist, you'd have to write your own, so you're not really any worse off if it doesn't do quite what you want. if(open one thing < 0) { perror...; exit...; } if(open another thing < 0) { perror...; exit...; } if(!malloc...) {perror... exit... } etc, I'd be half tempted to write a function just for *that*. BSD's err/warn family is a further refinement on this - it allows format/arguments, as I complained about in another post, and lets you specify what file to send output to, and the existence of err vs warn lets you avoid having exit as a separate step.