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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:53:03+00:00 2026-06-02T05:53:03+00:00

Hi I have a program written in C. I have global variables, arrays, dynamic

  • 0

Hi I have a program written in C. I have global variables, arrays, dynamic variables and also arrays etc… I send SIGHUP to my program and in handler I clean up the dynamic memory.And I want to restart my program with HUP.IS there a way to restart the program in c?. I want to exit and return from main in order to clean the memory that are handled by the static arrays in main and restart main.

Hi again. I edited the signal handler and added the execv in the handler. in the handler i have 2 functions. first is clean_up(); that cleans the dynamic arrays and the second is execv(). after sending HUP,first clean_up runs and then execv. but after a small time i have seg fault. but ,when i dont call the clean_up func, then it works fine?is there a problem in cleanup?. but cleanup works fine with other signals,termination signal for example

And a question for execv?.Does not it start the new program from main?.When I call execv, it does not start from main again

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

    Since you are on linux I think this is the cleanest way:

    int main(int argc, char **argv) {
        /* your program here */
    
        /* if you want to restart call this */
        if (execv(argv[0], argv)) {
            /* ERROR, handle this yourself */
        }
    
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a program in VB6. When I compile it and send it
I have a program written in C++ which uses dlopen to load a dynamic
I have a program written in C#. I want the Timer class to run
I have my program written in C++ and it is can be successfully compiled
I have a program written in C++, on Linux, compiled with -g. When I
I have a program written in VB.Net (Visual Studio 2008) that uses a DLL
I have a program written in C using ncurses. It let user input and
I have a client program written in .NET 2.0, that connects to the web
I have a program that is written in Ada, and I need to compile
I have a fully functional redact program written in haskell.it replaces all the words

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.