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 9022581
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:32:52+00:00 2026-06-16T05:32:52+00:00

I checked everywhere so I am hopefully not repeating a question. I want to

  • 0

I checked everywhere so I am hopefully not repeating a question.

I want to add a portable update feature to some C code I am writing. The program may not be in any specific location, and I would prefer to keep it to a single binary (No dynamic library loading)

Then after the update is complete, I want the program to be able to restart (not a loop, actually reload from the HDD)

Is there any way to do this in C on Linux?

  • 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-16T05:32:53+00:00Added an answer on June 16, 2026 at 5:32 am

    If you know where the program is saved on disk, then you can exec() the program:

    char args[] = { "/opt/somewhere/bin/program", 0 };
    
    execv(args[0], args);
    fprintf(stderr, "Failed to reexecute %s\n", args[0]);
    exit(1);
    

    If you don’t know where the program is on disk, either use execvp() to search for it on $PATH, or find out. On Linux, use the /proc file system — and /proc/self/exe specifically; it is a symlink to the executable, so you would need to use readlink() to get the value. Beware: readlink() does not null terminate the string it reads.

    If you want, you can arrange to pass an argument which indicates to the new process that it is being restarted after update; the bare minimum argument list I provided can be as complex as you need (a list of the files currently open for edit, perhaps, or any other appropriate information and options).

    Also, don’t forget to clean up before reexecuting — cleanly close any open files, for example. Remember, open file descriptors are inherited by the executed process (unless you mark them for closure on exec with FD_CLOEXEC or O_CLOEXEC), but the new process won’t know what they’re for unless you tell it (in the argument list) so it won’t be able to use them. They’ll just be cluttering up the process without helping in the least.

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

Sidebar

Related Questions

I've checked everywhere in my code and I could not find the reason why
I have read about piconets and scatternets. However, everywhere I've checked I do not
I recently inherited some code that someone else had written. I discovered that everywhere
Checked ActiveRecord, DataMapper, Sequel: some use globals (static variables) some require open db connection
I just want to ensure they are logged in before running any code. I
Here's the code I have: function transferq() { if (document.forms[0].elements['return'].checked == true) { document.forms[0].elements['returnhour'].disabled
I have a fairly detailed question about the right way to wrap a checked
This is my first question here (so be gentle :)). I've looked everywhere and
I have checked everywhere and I can't seem to locate the problem. The compiler
I would like to run my Objective-C code inside Xcode, but not for the

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.