go io_error ai_generated true

删除 /tmp/locked.txt: 设备或资源忙

remove /tmp/locked.txt: device or resource busy

ID: go/os-remove-file-in-use

其他格式: JSON · Markdown 中文 · English
80%修复率
86%置信度
0证据数
2025-07-01首次发现

版本兼容性

版本状态引入弃用备注
1.19 active

根因分析

尝试删除当前被其他进程或同一进程打开的文件。

English

Attempting to delete a file that is currently open by another process or the same process.

generic

解决方案

  1. 95% 成功率
    if err := file.Close(); err != nil { return err }; if err := os.Remove(path); err != nil { return err }
  2. 80% 成功率
    Use os.Rename to a temporary name then remove

无效尝试

常见但无效的做法:

  1. 70% 失败

    File remains, causing resource leak

  2. 90% 失败

    RemoveAll also fails if file is busy