Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8412319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T00:38:48+00:00 2026-06-10T00:38:48+00:00

I have a broad question: Suppose that I have a C++ program and I

  • 0

I have a broad question:

Suppose that I have a C++ program and I started to run it on a file in the background with some configuration which can be set internally. While it was running, I changed these internal configurations, compiled it and started to run it on another file.

Is this going to affect the previous instance which was already running in the background ? or since it was already up and running it won’t ? Any ideas on this is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T00:38:49+00:00Added an answer on June 10, 2026 at 12:38 am

    It is not safe to modify an executable that is running. As per What happens when you overwrite a memory-mapped executable?

    Under Linux, if you replace an executable while it is running, the
    results are unpredictable and it may crash.

    If you delete the file and compile a new version of the program then what will happen is very well defined. The already running instance will use the previous code, and that will be held in memory by the operating system until the program terminates. Any new instances will use the new code.

    The summary: You should make sure your build system deletes the old executable before recompiling, and so long as that is true then the recompile will not take effect until you rerun the program, otherwise the behaviour is undefined (read SIGSEGV).

    Appendix of sorts:

    JamesKanze rightly pointed out that the linker itself may delete the file before writing its output, if this is the case then it will always behave as if you’d deleted the file yourself before recompiling (the sane scenario). Looking at bfd/cache.c from the binutils cvs head:

    /* Create the file.
    
       Some operating systems won't let us overwrite a running
       binary.  For them, we want to unlink the file first.
    
       However, gcc 2.95 will create temporary files using
       O_EXCL and tight permissions to prevent other users from
       substituting other .o files during the compilation.  gcc
       will then tell the assembler to use the newly created
       file as an output file.  If we unlink the file here, we
       open a brief window when another user could still
       substitute a file.
    
       So we unlink the output file if and only if it has
       non-zero size.  */
    

    So at least with GNU LD this is guaranteed to be fine. This does not necessarily extend to other linkers, however.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A fairly broad question I know, apologies for that! So I have a data
I know this is a rather broad question, but have a class that has
Broad question is: Is there anything Telerik Reporting can do that SSRS (2005) cannot?
The question in broad terms: I have an object with a method that performs
A broad question. We have a client application that currently talks to a web
I know this sounds like a broad question but I can narrow it down
This is a really broad question, but I have come across it a couple
I know it is broad question but I am really confused. I have table
this is just kind of a broad question to get some starting points. I
This is somewhat of a broad question, but it is one that I continue

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.