'what' doesn't use perror to print open errors, Sys V/3.0

Guy Harris guy at auspex.auspex.com
Tue May 2 13:38:36 AEST 1989


>Yes, because there can be causes for fopen() failing that are not related
>to system calls the fopen() implementation may make.  For example, suppose
>there is a fixed array of FILE structures and they've all been allocated.
>No system call will occur, and any perror() you do will give completely
>mileading information about the problem.

In which case I'd prefer to use "open" to open the file, and "fdopen" to
turn it into a standard I/O stream; given the choice between using a
strictly conforming application not using anything outside the ANS which
just says "Sorry, I can't open your file", and one that uses POSIX
functions but tells me *why* it can't be opened, there'd better be a big
cost difference, or the latter'd better not be available on all the
platforms I'm interested in, or the former had better be better than the
latter for other reasons, 'cause I'm going to count the better error
disagnostic as a serious point in favor of the latter application....

>By now everyone must have seen at least one report "not a typewriter"
>due to a call to perror() under inappropriate circumstances.

I'd be willing put up with a few of those, if it's the price I have to
pay for better error diagnostics.  (I'd really have preferred it if
"errno" had been officially guaranteed to be set properly after failure
of things such as "fopen" (assuming that, in this hypothetical world,
some other error-reporting mechanism weren't used), but....)



More information about the Comp.bugs.sys5 mailing list