home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.sys.sgi:13069 comp.unix.questions:10557
- Path: sparky!uunet!cis.ohio-state.edu!rutgers!micro-heart-of-gold.mit.edu!xn.ll.mit.edu!ll.mit.edu!lebrun
- From: lebrun@ll.mit.edu (Steven F. LeBrun)
- Newsgroups: comp.sys.sgi,comp.unix.questions
- Subject: flock(), Files left locked after program terminates
- Message-ID: <9208310804.PN14234@LL.MIT.EDU>
- Date: 31 Aug 92 12:04:22 GMT
- Sender: news@ll.mit.edu
- Distribution: comp
- Organization: MIT Lincoln Laboratory, Lexington, MA
- Lines: 35
-
- I recently wrote a program on an SGI Indigo (IRIX 4.0.1) that uses
- flock() on a file. Due to a bug, the program failed to explicitly
- unlock the file. The program hangs in the call to flock() that
- locks the file whenever it runs a second time using the same file.
- The program is expected to wait for a locked file to become unlocked
- but since the program that locked the file has terminated, the file
- never becomes unlocked.
-
- Two factors may be important. The first is that exclusive locks
- were used. The second, is that the program was run a second time
- within a few minutes of the first run.
-
- I have two questions:
-
- 1) Is it a feature of flock() or a bug that when a program
- terminates normally that all advisory file locks remain?
- I thought that when you close a file, which is done
- implicitly when a program terminates, that the advisory
- lock was lost.
-
- 2) How do you get rid of an advisory lock on a file if the
- program that issued it is no longer running? Deleting
- the file works but I would like to know of a less
- destructive method.
- --
-
- +--------------------------------------------------------------------------+
- | Steven F. LeBrun | MIT Lincoln Laboratory, Group 91 |
- | | 244 Wood Street, Room LI-136 |
- | lebrun@ll.mit.edu (Internet) | Lexington, MA 02173-9108 |
- | lebruns@merlin (internal) | Phone:(617)-981-5742, FAX:(617)-981-0991 |
- +--------------------------------------------------------------------------+
- |"Hard as ligthning, soft as candlelight, |
- | dare you trust the Music of the Night?" - The Phantom |
- +--------------------------------------------------------------------------+
-