Is it safe to recompile an executable while it's running?

后端 未结 8 2213
再見小時候
再見小時候 2020-12-24 06:36

What happens if I recompile an executable while it\'s running? Does the operating system read all of the executable\'s contents into memory when it starts running it, so it

8条回答
  •  独厮守ぢ
    2020-12-24 07:15

    It depends.

    If the OS read the whole of the executable into memory and doesn't refer back to the disk image then yes you can recompile it while it was "in use".

    In practice this doesn't always happen. If the OS keeps a file handle open (like Windows does) on the executable this will prevent the file being deleted and/or overwritten.

    With Linux/Unix it is possible to overwrite a file that's "in use". See David Thornley's answer for a detailed explanation.

提交回复
热议问题