• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Locking
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Locking


  • Subject: Re: Locking
  • From: Gwynne <email@hidden>
  • Date: Wed, 16 Jun 2004 07:05:56 -0400

On Jun 16, 2004, at 6:44 AM, Wade Tregaskis wrote:
Under Classic MacOS you could find out which app had exclusive access to a file, although I don't know how; I only know that many applications (including the Finder) displayed this information at various times. It was particularly handy when you had a removable volume mounted and wanted to know why it can't be unmounted... under OS X it just throws up some useless generic error message.

Try the 'lsof' command. It doesn't always work, but it's good most of the time. The Finder and such don't use it for error messages because it's setuid root (you need root privs to read kmem) and aside from SecurityServer (Auth Services), the system's not in the practice of habitually running setuid programs. Also, lsof is slow.

Although usually it's just Terminal, which for some reason prevents most (all?) removable volumes being removed while it's open. Even disk images and the like. Weird.

If you watch the output of the lsof command, you'll find that any running process has it's current working directory open as a file descriptor. This is designed, among other things, to prevent the system from pulling the cwd out from under a process (though it can still happen by moving the directory). If the cwd of a shell is on a removable volume, that volume can't be unmounted until the shell cd's to a directory on another filesystem.

-- Gwynne, key to the Code that runs us all
Formerly known as Sailor Quasar.
Email: email@hidden
Web: http://musicimage.plasticchicken.com/
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Locking (From: "Gerriet M. Denkmann" <email@hidden>)
 >Re: Locking (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Comparing Executables
  • Next by Date: Defining a constant as private
  • Previous by thread: Re: Locking
  • Next by thread: Re: Locking
  • Index(es):
    • Date
    • Thread