title: launchd not recognizing manually started app
body: <p>I'm trying to accomplish the following with my tray app:</p>
  
  <ol>
  <li>MyApp.app should restart on crash</li>
  <li>MyApp.app should not launch on user-login (ie user has to manually start the app)</li>
  </ol>
  
  <p>I have a problem that if user manually starts the app, then listing in
  <code>launchctl list com.myapp</code> doesn't show the running app.</p>
  
  <p>If, however, I let the LaunchAgent launch app on user-login, then <code>launchctl list com.myapp</code> properly shows the app, and will restarts it on crash (or any non-zero exit code).</p>
  
  <p>Strangely enough, if user manually starts the app, launchd will try to launch it's own instance after several minutes. I can't even explain why this happens.</p>
  
  <p>My LaunchAgent plist example:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
     &lt;dict&gt;
        &lt;key&gt;KeepAlive&lt;/key&gt;
        &lt;dict&gt;
           &lt;key&gt;SuccessfulExit&lt;/key&gt;
           &lt;false/&gt;
           &lt;key&gt;AfterInitialDemand&lt;/key&gt;
           &lt;true/&gt;
        &lt;/dict&gt;
        &lt;key&gt;RunAtLoad&lt;/key&gt;
        &lt;false/&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;com.myapp&lt;/string&gt;
        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
           &lt;string&gt;/Applications/MyApp.app/Contents/MacOS/MyApp&lt;/string&gt;
        &lt;/array&gt;
     &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>