$ g++ program.cpp
$ ./a.out &
(program.cpp is modified.)
$ g++ program.cpp
How can the running process still produce accurate results if the executable is overwritten?
Because the old file still exists. The directory entry will point to a new file, but the old file will exist as long as it remains open. Once closed, it will finally be deleted. That is, on Unix. On Windows you would likely not be able to do this since the file is open and can not be overwritten.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With