Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!caen!hellgate.utah.edu!dog.ee.lbl.gov!nosc!crash!nusdecs!rwhite From: rwhite@nusdecs.uucp (0257014-Robert White(140)) Newsgroups: comp.unix.programmer Subject: Re: Determining if an existant file is open Message-ID: <1990Nov16.200945.14468@nusdecs.uucp> Date: 16 Nov 90 20:09:45 GMT References: <1990Nov16.023110.1305@csun.edu> Organization: National University San Diego Lines: 23 In article <1990Nov16.023110.1305@csun.edu> aeusejvn@csunb.csun.edu (Jon Nadelberg) writes: >Is there a way to check if a file is currently open and being used by >another process? Is there a way to "lock" a file so that other processes >can not access it? The things that come immedately to mind are: Use the exclusive flag when calling open(2) -- must be done every time. Allow multiple opens and have the processes do read and write locks as approprate, being shure to always lock before read (you shouldn't need manditory locks in this case, just be consistant). If the file is locked the file is busy. fnctl(2) or ioctl(2) I dont remember which right now. Do the "put process number in lock file" thing as in uucp. Any sutble differences between these thecniques should be considered based on the exact internals of the app. And then combine as many of these as is reasonable. Hope it was some help, Rob.