From StackOverflow's Locking Executing Files: Windows does, Linux doesn't. Why?:
From Oren Shemesh's answer:
Linux has a reference-count mechanism, so you can delete the file
while it is executing, and it will continue to exist as long as some
process (Which previously opened it) has an open handle for it. The
directory entry for the file is removed when you delete it, so it
cannot be opened any more, but processes already using this file can
still use it. Once all processes using this file terminate, the file
is deleted automatically.
Windows does not have this capability, so it is forced to lock the
file until all processes executing from it have finished.
From Perry Lorier's answer:
Linux does lock the files. If you try to overwrite a file that's
executing you will get "ETXTBUSY" (Text file busy). You can however
remove the file, and the kernel will delete the file when the last
reference to it is removed. (If the machine wasn't cleanly shutdown,
these files are the cause of the "Deleted inode had zero d-time"
messages when the filesystem is checked, they weren't fully deleted,
because a running process had a reference to them, and now they are.)