【问题标题】:kill process which is loaded by launchagents杀死由启动代理加载的进程
【发布时间】:2015-04-03 11:34:16
【问题描述】:

我的应用程序(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。

那么任何人都可以告诉我如何实现这一点?

【问题讨论】:

    标签: macos launchd


    【解决方案1】:

    这是……具有挑战性的。这是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>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-07-25
      • 1970-01-01
      • 1970-01-01
      • 2011-12-15
      相关资源
      最近更新 更多