开发者

Editing source during program execution

开发者 https://www.devze.com 2023-04-12 10:38 出处:网络
I have a C program which calls several functions from different 开发者_开发知识库files, and in compilation I link all the object files together to make the binary. I then start execution of the progra

I have a C program which calls several functions from different 开发者_开发知识库files, and in compilation I link all the object files together to make the binary. I then start execution of the program. Now I would like to edit the source of various files and compile the new versions. This will overwrite the old object and binary files.

Will doing this affect execution of the current program? Will it now be linking the new object files? If I overwrite the binary being run will this cause execution to be halted, or impact it in some other way? Or is the code stored in a place where it cannot be overwritten at the start of execution?

I'm using gcc to compile my code.


On Unix, letting gcc replace the executable will have no impact on the running program.

The way it works is that the old executable will remain on disk for as long as the program is running, so that the operating system can refer to it if needed. There will no longer be a directory entry pointing to the old executable, and the disk space will be reclaimed when the old instance of the program stops.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号