'what' doesn't use perror to print open errors, Sys V/3.0
Doug Gwyn
gwyn at smoke.BRL.MIL
Mon May 1 13:58:33 AEST 1989
In article <1153 at aplcen.apl.jhu.edu> bink at aplcen.apl.jhu.edu (Greg Ubben) writes:
>I regularly use perror() to report the failure of an fopen(). It works on
>all the systems I've used because, of course, the fopen() doesn't make any
>other system calls after the open(). Is this really a bad thing to do?
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.
By now everyone must have seen at least one report "not a typewriter"
due to a call to perror() under inappropriate circumstances.
If you have a fairly high degree of certainty that nothing could have
gone wrong that didn't involve a system call failure, then feel free to
use perror(), but you're always taking a risk when using perror() after
a non system-call library function.
More information about the Comp.bugs.sys5
mailing list