I'm not sure but I think you're asking if one process
can tell if a file was opened for read/write by another
process... correct?
In the function...
int fcntl(int fildes, int cmd, /* arg */ ...);
fildes must be a file descriptor to an open file
therefore, in order to use this, the current (or parent)
process should have already opened the file so you should
not get a "closed" file error.
You can use fcntl() to try to set an exclusive lock on a file
that you have previously opened and if another process
has opened this file for write access, fcntl() will fail. However,
if the other process has not opened the file for write access
and just for reading (i.e. O_RDONLY), then fcntl() will not fail.
Anyway, this is all system call level stuff.
If you're looking for a command line program to tell you
if a file is open or not, try lsof (LiSt Open Files) look at:
http://www.ensta.fr/internet/unix/sys_admin/lsof.html