[VPM] File locking

Darren Duncan darren at DarrenDuncan.net
Mon Oct 6 23:03:28 CDT 2003


Peter Scott said:
>If a process flock()s a file and exits without unlocking it, the file is automatically unlocked on process exit no matter how the process ended, right?

Without knowing much about the internals of flock(), I would expect that the file would be unlocked.

Given what functionality flock is supposed to provide, I would expect the operating system is keeping a table in memory that maps files to locks on them, with the locks being associated with processes.  Or more specifically, since honoring flock is not mandatory, I suspect this table probably is a list of mutexes which just so happen to be associated with file system files, but technically wouldn't have to be.  When the process is no longer running, the OS would know, and it would purge resources used by that process from the lock table.  That is what I would expect to happen.

OTOH, if you are using 'lock files', then no, the lock would not be cleared if the process dies.

Of course, you could still look for another opinion.

-- Darren Duncan



More information about the Victoria-pm mailing list