11

Is there a way to tell OS X Lion to disable auto-termination for a given application that you do not want to auto terminate?

FYI Lion is a quitter if you did not already know, what if you don't want it to be for a certain Applicaiton.

Lion will quit your running applications behind your back if it decides it needs the resources, and if you don’t appear to be using them. The heuristic for determining whether an application is “in use” is very conservative: it must not be the active application, it must have no visible, non-minimized windows — and, of course, it must explicitly support Automatic Termination.

For example, say I don't want TextEdit to automatically quit when I have no TextEdit windows open and switch to another Application.

After taking a look at Mac App Programming Guide section for Automatic Termination I figured I would try adding the NSSupportsAutomaticTermination key with the value of No to the Info.plist file for TextEdit. (Did not work: TextEdit crashes on open.)

To be noted, the file did not include NSSupportsAutomaticTermination key (which means that Apple was using NSProcessInfo to enable auto termination), so adding a key would probably have no effect anyways since NSProcessInfo overrides what is in the plist file. (Verified this does not work, by self-signing TextEdit with a modified Info.plist including the NSSupportsAutomaticTermination key and value of No).

One side effect noted is that changing anything in the Info.plist file causes TextEdit to crash when opening. The cause is noted from the crash log as "code signature invalid", which means that the TextEdit app and all its contents are code signed. The workaround is to self-sign the app using the codesign command and a self-signed root certificate as noted in Code Signing task.

After what I have tried so far, TextEdit still obeys Automatic Termination.

8
  • 1
    So... if you self-sign the app, does it work?
    – jtbandes
    Apr 16, 2012 at 17:29
  • 1
    Nope, program still auto terminates even after self-signing, regardless of what I have added to Info.plist
    – MrDaniel
    Apr 16, 2012 at 17:31
  • 1
    Have you tried downloading the example source for TextEdit that Apple provides with the dev tools and editing (or removing) the NSProcessInfo stuff that registers for auto termination?
    – Cajunluke
    Apr 16, 2012 at 20:04
  • No have not tried that, that should work in this case. But this question is beyond TextEdit. It is more of a question of can we work around this with out developer source code level intervention. Since we will not always have access to the source code for apps supporting Auto Termination.
    – MrDaniel
    Apr 16, 2012 at 20:22
  • 1
    "This is how Apple works" that is just bogus. This is a new feature, not well advertised at that. From Apples Docs its not even clear what is required for the OS to Auto Terminate a program. And Apple fails to advertise this nor mention it on the Lion features page for end users. I think its something new Apple is trying. If end user don't like this they should voice Apple and Developers so they can make it better.
    – MrDaniel
    Apr 18, 2012 at 0:07

2 Answers 2

14

Your wish is my Terminal command ;-)

defaults write -g NSDisableAutomaticTermination -bool yes

Note that since Automatic Termination doesn't really quit the applications, but rather hides them, they must have been properly quit for this to take effect.

4
  • 2
    Excellent, good find user22760. Tried it as noted above and it does work, thanks. The test case of TextEdit.app no longer auto terminates after running the defaults ... and then opening and then quitting TextEdit. Upon reopening TextEdit it will no longer autoterminate with no windows open, and running in the background.
    – MrDaniel
    May 14, 2012 at 17:09
  • Interesting. After trying out this command, it does indeed work. However, trying to undo it has proven to be more difficult. defaults write -g NSDisableAutomaticTermination -bool no, or false, or deleting key has no effect and the applications will not Automatically Terminate
    – DrFloyd5
    Aug 16, 2012 at 1:32
  • This miracle command works for me on Mavericks ! It takes effect when coming back to the session or when opening a new session. Jan 19, 2014 at 12:05
  • Thanks so much for the added instruction to launch and manually quit the app and then relaunch it to see the effect properly!
    – 2540625
    Dec 4, 2015 at 4:19
1

There's a sure-fire way to fix this, if your hardware supports it. You can upgrade from Mac OS X 10.7 (Lion) to Mac OS X 10.6 (Snow Leopard).

While not all hardware that will run Lion can support this improved operating system (sadly, my mid-2011 MacBook Air does not), it includes such features as non-auto-termination, Rosetta (which enables Intel processors to run software compiled for PPC processors), and compatibility with per-app recording features in the excellent WireTap Studio.

As with any upgrade, some features are lost (such as Mission Control, Launch Pad, some gestures) and some operating system quirks take some getting used to (the direction of scrolling is reversed, for instance), but all in all, it's a fine upgrade.

4
  • 2
    Good point, but for most users Auto Termination is not worth rolling back to Snow Leopard over, its just a minor annoyance to some users, I am not one of them.
    – MrDaniel
    Apr 19, 2012 at 20:31
  • 1
    It's an extreme solution, to be sure, but this is one of several ways Snow Leopard is superior to Lion. The cumulative effect of them might induce someone to want Snow Leopard. That said, I'm just learning to live with it, as other features of Lion (particularly related to iCloud) make it worth putting up with the drawbacks.
    – Daniel
    Apr 19, 2012 at 21:16
  • The question is about Lion. May 11, 2013 at 18:30
  • 1
    @GrahamPerrin so was my answer. My point is that this is one of many things that Lion broke, and one solution might be to not run Lion.
    – Daniel
    May 11, 2013 at 21:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .