获得徽章 0
- #OpenClaw今天想篡位了吗# 为什么 pkill -9 -f openclaw-gateway 之后服务会自动恢复
根本原因:你在 macOS 上运行的,launchd 注册了一个带 KeepAlive=true 的 LaunchAgent。
机制说明
launchd 是 macOS 的进程守护系统。OpenClaw 安装时会在
~/Library/LaunchAgents/ai.openclaw.gateway.plist
注册一个 LaunchAgent,其中有两个关键配置:
<key>RunAtLoad</key><true/> <!-- 登录时自动启动 -->
<key>KeepAlive</key><true/> <!-- 进程退出后自动重启 -->
KeepAlive=true 的语义是:无论进程以何种方式退出(包括被 SIGKILL 强制杀死),launchd 都会立即重新拉起它。
所以执行 pkill -9 的流程是:
pkill -9 → 进程被系统强制终止 → launchd 检测到 pid 消失 → 自动重新启动
-9 (SIGKILL) 无法被进程捕获或忽略,进程必然退出;但这恰恰触发了 launchd 的 KeepAlive 逻辑。
openclaw竟然会有这种机制
展开评论1
![[惊讶]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_68.1e326db.png)
![[尴尬]](http://lf-web-assets.juejin.cn/obj/juejin-web/xitu_juejin_web/img/jj_emoji_11.8824107.png)