osx - How to find out process that uses file but is not using at the moment?

07
2014-07
  • Luiz Berti

    Background

    I, as well as many other people according to Apple's support forums, am having some trouble with the audio settings on my Mac. Whenever the computer sleeps or powers off, the audio resets to the internal speakers and the system won't recognise what is plugged in the audio jack. Resetting NVRAM or the SMC will fix the problem until the machine either sleeps or gets powered off, when the problem will persist.

    The Idea

    Turns out that deleting the following files:

    • /Library/Preferences/Audio/com.apple.audio.DeviceSettings.plist
    • /Library/Preferences/Audio/com.apple.audio.SystemSettings.plist

    And then rebooting will also do the temporary fix, but then again, that requires rebooting. My idea is to write a bash script that rms both files and then kills the process that uses them. The problem however is to find out what process loads them. Unfortunately lsof doesn't work, cause the process doesn't use them constantly, they get loaded when the process starts and thats it.

    The Question

    How would I find out which process is loading the files everytime I reboot, given that the process doesn't keep constant access to the file and that it might be loading them before login?

    Bonus points if you have had this problem on your Mac before and knows how to fix it.

  • Answers
  • Chris

    *NIXes have daemon called "audit". You can set this daemon to watch for any chnages to the files:

    MAN: https://developer.apple.com/library/mac/documentation/Darwin/Reference/Manpages/man8/audit.8.html

    It's OpenBSM and here is some more information about it:

    http://derflounder.wordpress.com/2012/01/30/openbsm-auditing-on-mac-os-x/


  • Related Question

    osx - Optical Audio out stuck on on a MacBook
  • Clinton Blackmore

    Apple have made an interesting headphone port for the MacBook (and some other Intel Mac models). It works like a standard jack:

    • nothing plugged in -> audio comes out of built-in speakers
    • headphones/external speakers plugged in -> plays through headphones/external speakers

    but you can also use a special adapter (which trips a tiny microswitch) to get an optical audio out signal (which you can presumably plug into a nice surround-sound system).

    This is all well and good except when, like auto-tracking, it doesn't work, and you are left with nothing to adjust. Users report that they get no sound when they have nothing plugged in and that a red light emanates from the headphone port. If you go to System Preferences -> Sound -> Output, it will say (IIRC) "Optical Out" instead of "Internal Speakers".

    The only solution I'm aware of is to try to reset the switch by inserting and removing a set of headphones or a toothpick, perhaps wiggling it inside of the port, and hoping that you luck out and get it.

    Are there other ways to fix this problem? Does anyone know where the microswitch is or have a good technique to reset it?


  • Related Answers
  • Jon

    I've used toothpicks or half of a Q-Tip - really, anything non-metallic that will fit - to do a counter-clockwise sweep of the inside of the opening with success. I've seen various reports as to where the switch may be; I typically just sweep until it's fixed. If you have iTunes open and playing or the Sound PreferencePane of System Preferences up you'll be able to tell when you've hit the switch.

  • PghMIke

    Toothpick and/or plugging and unplugging regular headphones worked for (I was doing both, not sure which did the trick, but I bet it was the toothpick).

  • daviewales

    I tried the toothpick, and couldn't get it to work. (I was probably doing it wrong.)

    However, after reading this thread, I tried plugging my headphones in, then pulling them out slowly while jiggling the headphone plug. This fixed it straight away.

  • Alan

    Plug in your headphones, (they will work) now turn off the computer. Remove the headphones and turn on the computer.