Penguin
Note: You are viewing an old revision of this page. View the current version.

Text file busy

This occurs when you try and write to a file that is currently being run by the kernel.

For example
$ cp /bin/cat example $ ./example & 1? 17238 1?+ Stopped ./example $ echo foo >example bash: example: Text file busy
Note, that although you cannot overwrite the file, you can remove it
$ rm example
And then replace it
$ cp /bin/kill ./example

The reason you can do this is that the kernel will not free the disk space used by the program until the last use of it is free'd, ie: the program exits. If the computer crashes and doesn't get a chance to free these, on a reboot fsck will usually complain about "deleted inode has zero dtime" (the inode was deleted, but never free'd because it was still in use at the time the program crashed). Unix can do this because it refers to a file by it's inode number, and it may have 0 or more filenames. Opening a file and then deleting it (and keeping hold of the filehandle) is a common way of using a temp file, since you know it will be removed from the disk when your program exits. Note that MicrosoftWindows cannot do this, since it refers to a file by name. Thus, you cannot remove a file that is in use in Windows.