home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / sgi / 13069 < prev    next >
Encoding:
Internet Message Format  |  1992-08-31  |  2.3 KB

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