我正在为我的应用程序编写 Launchd,以便在 OSX 中使用 KeepAlive SuccessfulExit 异常退出时重新启动它

I am writing Launchd for my App to relaunch it when exits abnormally using KeepAlive SuccessfulExit in OSX

我正在为我的应用程序编写 Launchd,以便在 OSX 中使用 KeepAlive SuccessfulExit 异常退出时重新启动它 当我通过强制退出应用程序

来检查它时,它对我不起作用

见代码

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.name.myApp</string>
    <key>RunAtLoad</key>
    <true/>
    <key>ProgramArguments</key>
    <array>
        <string>/Users/al/bin/myApp.sh</string>
    </array>
    <key>KeepAlive</key>
    <dict>
        <key>SuccessfulExit</key>
        <true/>
    </dict>
</dict>
</plist>

你搞反了。来自 launchd.plist(5):

       SuccessfulExit <boolean>
       If true, the job will be restarted as long as the program exits
       and with an exit status of zero.  If false, the job will be
       restarted in the inverse condition.

将密钥设置为<false/>,你应该没问题。