我在使用 Linux 4.0.4 计算机时偶尔会遇到“文本文件繁忙”错误。我读到当错误发生时,内核会阻止对正在“使用”的文件进行修改。
因此,我确保文件已打开(如 lsof 中所列),然后对其进行修改,一切正常,并且不会发生“文本文件繁忙”错误。
那么如何触发错误呢?
lcd*_*047 10
“文本文件繁忙”意味着进程在运行时试图修改可执行文件(“文本”是关于一个.text段,而不是一个文本文件)。要触发它:
$ cp /usr/bin/yes .
$ ./yes >/dev/null &
[1] 27417
$ cat /dev/null >yes
-bash: yes: Text file busy
$ kill %1
[1]+ Terminated ./yes > /dev/null
$ cat /dev/null >yes
$ ls -s yes
0 yes
Run Code Online (Sandbox Code Playgroud)