Testing for a file in a write process

Testing for a file in a write process

Post by Lowell Gilber » Fri, 31 Jul 1998 04:00:00




> How can you tell if a file is in the process of being written to.
> Specifically, how can you tell if a file is in the middle of an
> FTP transfer without spending a lot of time querying the unix
> stat struct.  Our processing that surrounds this issue is time
> critical.  Any ideas would be appreciated.

The "traditional" answer is to FTP the file to a temporary filename,
and only move it to its permanent name after the transfer is complete.
This may or may not meet your "time critical" requirements, but it
avoids the race conditions and system load of relying on stat(2).
--

"The first cup of coffee recapitulates phylogeny." -- Ted Sturgeon, allegedly