Is this launchd plist broken or is it just me? I was reading a post about using Bittorrent Sync on OS X that includes a launchd plist that's supposed to keep the app running in the event that it crashes. It doesn't seem to work, though, since I've had the app crash and not relaunch. I'm looking for help fixing the plist.

The plist looks like this:

&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;Crashed&lt;/key&gt;
        &lt;true/&gt;
        &lt;key&gt;SuccessfulExit&lt;/key&gt;
        &lt;false/&gt;
    &lt;/dict&gt;
    &lt;key&gt;Label&lt;/key&gt;
    &lt;string&gt;sync.com.tjluoma.bittorrentsync&lt;/string&gt;
    &lt;key&gt;ProgramArguments&lt;/key&gt;
    &lt;array&gt;
        &lt;string&gt;/usr/bin/open&lt;/string&gt;
        &lt;string&gt;-W&lt;/string&gt;
        &lt;string&gt;-a&lt;/string&gt;
        &lt;string&gt;BitTorrent Sync&lt;/string&gt;
    &lt;/array&gt;
    &lt;key&gt;RunAtLoad&lt;/key&gt;
    &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


The "clever" bit is using /usr/bin/open to launch the app, with -W to make sure that open waits for the app to exit. But I think that's also why it doesn't actually work. If I'm reading this right, the app will only relaunch if /usr/bin/open crashes, not if Bittorrent Sync crashes. For the above approach to work, open would need to return error status if the app it opened had crashed (and this does not happen).

I know I could fix this by dropping open and instead hard coding the path to the executable as /Applications/BitTorrent Sync.app/Contents/MacOS/BitTorrent Sync. But is there an alternative that doesn't require hard-coding the full path? Using open would be elegant, if it worked.
It was as I expected. The version in the question doesn't re-launch the app, because /usr/bin/open doesn't return an error status when the app crashes. I wasn't able to find a better way than hard-coding the path to the executable, so I'm now using the following.

&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;Crashed&lt;/key&gt;
                &lt;true/&gt;
                &lt;key&gt;SuccessfulExit&lt;/key&gt;
                &lt;false/&gt;
        &lt;/dict&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;com.getsync.bittorrentsync&lt;/string&gt;
        &lt;key&gt;Program&lt;/key&gt;
        &lt;string&gt;/Applications/BitTorrent Sync.app/Contents/MacOS/BitTorrent Sync&lt;/string&gt;
        &lt;key&gt;RunAtLoad&lt;/key&gt;
        &lt;true/&gt;
&lt;/dict&gt;
&lt;/plist&gt;


I've verified that this does successfully re-launch the app if it crashes.

A more easily downloadable version of this can be found at https://gist.github.com/atomicbird/ff2de46a594cdb5c8e69