Date: Fri, 19 May 1995 12:54:31 -0400
From: Scott Schwartz <schwartz@galapagos.cse.psu.edu>
In Unix, the right way to see if a file is readable is to open() it for
reading and check the return value. Even assuming only UFS, a stat
followed by an open is wrong because it introduces a race condition.
I understand that, if I intend to read a file, the only way is to open it.
Then I can see if I can read it. I do agree.
But if all I want to check is the file readability, with no intent to read it,
I suppose file-readable? should at least use open or access, not a simple stat
(as is done in scsh 0.3). As I think access(2) does the same checks than
open, just without opening the file, I suggested this way.
Bruno.
|