[comp.lang.c] Detecting if a file is busy

nto0302@dsacg3.dsac.dla.mil (Bob Fisher) (06/28/91)

How can one process tell if a file is open in another process?

I'm writing a daemon that takes files placed into an input directory but
the daemon needs to wait until the file is closed by the process that
is creating it.

This is being developed on an AT&T 3b2 running SVR3.2 but will eventually
be ported it to other hardware.
-- 
Bob Fisher
US Defense Logistics Agency Systems Automation Center
DSAC-TOL, Box 1605, Columbus, OH 43216-5002     614-238-9071 (AV 850-9071)
bfisher@dsac.dla.mil		osu-cis!dsacg1!bfisher

mouse@thunder.mcrcim.mcgill.edu (der Mouse) (07/01/91)

In article <3300@dsacg3.dsac.dla.mil>, nto0302@dsacg3.dsac.dla.mil (Bob Fisher) writes:

> How can one process tell if a file is open in another process?

One can't really.

> I'm writing a daemon that takes files placed into an input directory
> but the daemon needs to wait until the file is closed by the process
> that is creating it.

The creating process will have to cooperate somehow.  There is no
portable way to determine this otherwise; about all you can do is
grovel through kernel data structures, and even then you can't always
get it right (suppose another machine has it mounted via NFS and a
process there is writing it).

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu