![]() It depends on the kernel, and on some kernels it might depend on the type of executable, but I think all modern systems return ETXTBSY (” text file busy“) if you try to open a running executable for writing or to execute a file that's open for writing. (See also the clarifying answer I just posted to my own question.) (And I wonder why people aren't complaining that ld may now be breaking their hard links, or changing file ownership, and like that.)Īddendum: The question wasn't specifically about cc/ ld (although that does end up being a big part of the answer) the question was really just "How come I never see ETXTBSY any more? Is it still an error?" And the answer is, yes, it is still an error, just a rare one in practice. And I don't see any mention of this on ld's man page. I can't quite tell if it's doing this all the time, or only if it needs to (that is, perhaps after it tries to overwrite the existing file, and encounters ETXTBSY). It looks like someone may have tweaked ld to unlink its output file and create a new one, just to eliminate errors in this case. So my questions are, how does this work, is it documented anywhere, and is it safe to depend on it? There's even a specific errno value, ETXTBSY, that covers this case.īut for quite a while now, I've noticed that when I accidentally try to overwrite a running executable (for example, by firing off a build whose last step is cc -o exefile on an exefile that happens to be running), it works! I have a question about overwriting a running executable, or overwriting a shared library (.so) file that's in use by one or more running programs.īack in the day, for the obvious reasons, overwriting a running executable didn't work.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |