杀戮过程由发起人加载

时间:2015-04-03 11:34:17

标签: macos launchd

我的应用程序(my.app)会将一个plist文件(com.agent.plist)添加到/Library/LaunchAgents,当my.app运行时会触发另一个应用程序(agent.app)。我知道agent.app将作为非root权限加载,因为它位于/Library/LaunchAgents中。 下次,在my.app的卸载脚本中,我希望用户launchtl remove com.agent.plist来终止agent.app进程。但卸载脚本是由root权限触发的,所以看起来好像使用sudo launchtl remove com.agent.plist,这不起作用,因为agent.app不归root所有。

所以任何人都可以告诉我如何实现这个目标?

1 个答案:

答案 0 :(得分:0)

这是......具有挑战性。这是How can you start a LaunchAgent for the first time without rebooting, when your code runs as a LaunchDaemon?的反转版本。

您可以使用该答案中给出的相同代码;只需将load -w <your_plist>替换为remove <your_bundle>