Say I compile some code and make it run. It will take 10 mins to finish. In the meantime, if I change some parameters in the code and compile it again using a separate terminal window and run it too (so there’s now two programs running simultaneously using the same code), does the second run affect the first running program as the first compiled output is replaced by the second compiled output?
>Solution :
There are 3 scenarios possible :
-
On Windows executable file will get locked for writing and removal while it is being executed so build will just fail.
-
On Linux executable file is not necessary protected from modification or removal while it is being executed.
2.1. If file is deleted from FS and then a new file is created with the same name then old file content will still remain until already running executable exits while new executable will use new file. So old executable will continue to run normally while new one will be ready to work as well.
2.2. If file is opened for writing and overwritten with new content then already running executable will be using new machine code which is most likely incompatible with the existing program state and will lead to crashes.