Skip to content

ETXTBSY: Text file busy

On a recent Freakshow episode, the question arose what would happen if a running executable were to be changed while still running. As it turns out, the behaviour is different, depending on the platform and even possibly the filesystem.*)

On a Solaris 10 (x86) system, the following happened:
$ gcc hallo.c -o hallo.exe
$ gcc hallo_capital.c -o hallo_capital.exe
$ ./hallo.exe
Hallo Welt!
Hallo Welt!
Hallo Welt!
[...]
Now, on a different terminal we overwrite (but don't unlink) it:
$ cat hallo_capital.exe > hallo.exe
On the first terminal again, "Welt" changes to "WELT":
[...]
Hallo Welt!
Hallo WELT!
Hallo WELT!
Hallo WELT!
When I changed even more (e.g. using printf instead of puts), the program would stop or even crash.

So, what do other platforms do? On Linux 3.12.0-rc5 we're not able to overwrite the running executable and ETXTBSY is returned:
$ cat hallo_capital.exe > hallo.exe
bash: hallo.exe: Text file busy
Or, via strace:
open("hallo_capital.exe", O_RDONLY|O_LARGEFILE) = 3
dup2(3, 0)                              = 0
close(3)                                = 0
_llseek(0, 0, [0], SEEK_CUR)            = 0
open("hallo.exe", O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0666) = -1 ETXTBSY (Text file busy)
The same happens on a FreeBSD 9.1 system.

Interestingly, the running executable can be overwritten on Darwin (so much for the BSD part in MacOS), but the output does not change, i.e. the running binary is not modified.

*) [Citation needed]

VMware is full of shit

I wanted to download VMware Fusion (VMware Workstation for Macs) so I went to the VMware site and clicked on "Download Free Trial" and got an instant download dialog. Once the 511 MB file was on my disk I thought "Hm, before I install that thing, let's see its checksum is valid!".

Looking for the SHA1 checksum I ended up at this place, but what's that? Two versions of the same product? Let's see: apparently the version I downloaded was called "VMware Fusion 6 with VMware Tools and a 12-month complimentary subscription to McAfee VirusScan Plus" (with said 511 MB in size) and the other version is "VMware Fusion 6 Only" with only 234 MB in size. Are you kidding me?

I know, other companies bundle their programs with pesty add-on programs and sneaky toolbars as well, but holy shit! A more than doubled download size to include a crappy virus scanner as your default download option? You must be out of your mind!