Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if a program is compiled while another instance is already running?

Tags:

c++

$ 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?

like image 700
galath Avatar asked Dec 12 '22 03:12

galath


1 Answers

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.

like image 133
Will Hartung Avatar answered May 20 '23 01:05

Will Hartung