windows - Is it safe to recompile an executable while it's running? -
What if I recompile the execute executable? Does the operating system read all the executable content in memory when it starts running, will it ever read this new executable file? Or will the sections of this new executable file be read, which has not changed, perhaps leading to undefined behavior?
What if I have a script running which repeatedly says executable in a loop, and I'm running the script, while executable. Is it a guarantee that the future execution of the loop will be new executable, and only because of the orientation that was in progress when the switch was made could be corrupted?
My OS is Linux, I'm also curious about what happens on Windows.
Since it is a traditional compiler, which writes an executable file, let's follow it in linux Are there.
The first thing to know is that the Linux file name does not directly reference the file, but rather for a directory entry, which is independent of the filename. The file does not really need to have a filename, but if it is not, it can be difficult to reference it.
If any process is using the file, and you change it or delete it, then the process will continue to use that file through its directory entry. Any new process using the file, or seeing it, will receive the new version (if you have changed it) or fail to find it (if you have deleted it). Once all the processes are through the old file, it will be removed from the file system.
Therefore, if you recompile and create new executables of the same name, then you will not affect the walking process. It will continue to use the old executable. Any new process trying to open the file will be new if you have got the system ("foo"); In a loop, every time he executes it, it will look like what is the correct meaning of file name foo.
Windows handles files differently Normally, if there is a process using the file, then the file is locked and can not be removed or changed.
Comments
Post a Comment