Subject: Re: bin/19849: Race conditions in compress
To: None <>
From: David Laight <>
List: netbsd-bugs
Date: 01/15/2003 17:47:10
> IMHO, it's better to open the file and use ENOENT == errno to decide
> whether the file exists or not.
>         if ((ifp = fopen(in, "r")) == NULL) {
>                 cwarn("%s", in);
>                 return;
>         }

You need to do the underlying open with O_NONBLOCK set just in
case a char special is specified (which might block - eg a tty
line waiting for carrier).

This starts getting hard if you want (need?) to keep portability
with non-unix systems.

OTOH there are an awful lot of these sort of race conditions
lurking, and fixing them will do no harm.


David Laight: