You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

macOS Sonoma中launchctl bootout执行失败,报EIO输入输出错误

解决macOS Sonoma 14.4.1中launchctl bootout报错EIO(错误码5)的问题

问题背景

我的macOS应用在macOS 14.4.1(内核Darwin v23.4.0,Sonoma)无法运行,执行以下命令移除启动代理时失败:

/bin/launchctl bootout gui/501 /Library/LaunchAgents/com.company.name.plist

错误码为5,对应EIO“输入输出错误”,该操作在旧版macOS可正常执行。启动代理的Mach-O可执行文件已完成Apple签名和公证,对应的plist文件内容如下:

<?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>com.company.name.launch.agent</key>
    <true/>
    <key>LimitLoadToSessionType</key>
    <array>
        <string>LoginWindow</string>
        <string>Aqua</string>
    </array>
    <key>Disabled</key>
    <false/>
    <key>Label</key>
    <string>com.company.name</string>
    <key>Program</key>
    <string>/Library/PrivilegedHelperTools/com.company/name</string>
    <key>ProgramArguments</key>
    <array>
        <string>-a</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <true/>
</dict>
</plist>

可能的原因及解决步骤

1. Session权限与路径格式问题

Sonoma对launchctl的权限管控更严格,直接用gui/501指定UID可能存在会话匹配问题,尝试替换命令为:

launchctl bootout gui/$(id -u) /Library/LaunchAgents/com.company.name.plist

或切换到目标用户会话执行:

su - $(id -un 501) -c 'launchctl bootout /Library/LaunchAgents/com.company.name.plist'

2. plist配置兼容性问题

Sonoma对LaunchAgent配置的校验更严格,排查以下点:

  • 路径错误:检查/Library/PrivilegedHelperTools/com.company/name路径是否存在,注意路径中的com.company/name是否应为com.company.name(可能是分隔符误用)
  • 会话类型冲突:同时指定LoginWindow和Aqua会话类型可能引发兼容性问题,尝试只保留Aqua:
    <key>LimitLoadToSessionType</key>
    <array>
        <string>Aqua</string>
    </array>
    
  • 自定义键值:plist中的com.company.name.launch.agent是自定义键,虽不影响功能,但Sonoma可能对非标准键值有隐性校验,可尝试移除后测试。

3. 进程状态异常

如果代理进程处于僵死状态,会导致bootout操作失败:

  1. 查找进程PID:
    pgrep -f com.company.name
    
  2. 强制终止进程:
    kill -9 <PID>
    
  3. 再次执行bootout命令。

4. 系统完整性保护(SIP)影响

Sonoma的SIP可能限制了对/Library/LaunchAgents的操作,可临时重启到恢复模式禁用SIP,测试操作完成后再重新启用SIP。

内容的提问来源于stack exchange,提问作者c00000fd

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.27 02:58:25