Is it possible to modify source binary in Linux if any process spawned from that binary is still running?
Will OS allow to perform write operation on that binary?
Is it possible to modify source binary in Linux if any process spawned from that binary is still running?
Will OS allow to perform write operation on that binary?
Try it:
cd $(mktemp -d)
cp /bin/sleep .
./sleep 120 &
echo test > sleep
The shell’s redirection operator changes the file in-place, and this fails with a “text file busy” error.
It is however possible to replace the file:
cp /bin/ls sleep
This is how, for example, packages can be updated while the program they contain is running. The old file remains accessible to the running process as long as it keeps running.