How to check if a file is opened?

How to check if a file is opened?

Post by Kari E. Hurt » Fri, 05 Nov 1993 02:26:56



? I am working on several C programs which will access the same file.
? I am wondering if there is a way to check if a file is already opened
? by other program in a C/UNIX envi.

You can't.

You possibly wanna use some file locking methods. Check lockf/flock.

--
- K E H                                      /  El?m? on monimutkaista

 
 
 

How to check if a file is opened?

Post by lm » Fri, 05 Nov 1993 01:17:55


I am working on several C programs which will access the same file.
I am wondering if there is a way to check if a file is already opened
by other program in a C/UNIX envi.

Many thanks!!
--
Liming Ren  
Dept. of Mathematics             |  231 West 18th Avenue
The Ohio State University        |  Columbus, Ohio43210

 
 
 

How to check if a file is opened?

Post by John Ellithor » Fri, 05 Nov 1993 08:45:04



Quote:> NNTP-Posting-Host: math.mps.ohio-state.edu
> I am working on several C programs which will access the same file.
> I am wondering if there is a way to check if a file is already opened
> by other program in a C/UNIX envi.

I think there are file locking routines (flock() ?), which can lock a file or
see if a file is locked.  This is outside my realm of knowledge.  I've just
seen it a couple of times.  Hope this gives you a place to start...

John
--
===============================================================================

Dept. of Physics, Rm 26-319               | Phone   : (617) 253-4028  Office
Massachusetts Institute of Technology     |           (617) 253-3072  Lab
Cambridge, MA  02139                      |           (617) 236-4910  Home
===============================================================================