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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:57:50+00:00 2026-06-07T18:57:50+00:00

i have done my program mainApp that owns main() method and main() creates 5

  • 0

i have done my program mainApp that owns main() method and main() creates 5 threads, threads do some operations.. so on.

now im just wondering if my program crashes. So im gonna monitor my mainApp whether it is working or stopped. if stopped Im gonna restart/reboot the whole system.

mainApp and monitoring program have to run at the same time and monitor prog should check mainApp’s status.

any suggestions pls.

PS: im om linux kernel 2.6.29.

  • 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-07T18:57:53+00:00Added an answer on June 7, 2026 at 6:57 pm

    Unless you want a general purpose monitor, your program can monitor itself.

    When the program first starts, the program itself is the monitor. Since the program is just starting, there is no “mainApp” running, so it forks itself off. The child process assumes the role of the “mainApp”. The monitor now waits for the child process to die. When the child process dies, it checks the status, and ff a restart is decided, then it forks again.

    int main () {
        /*...startup...*/
        int status;
        bool restart = true;
        while (restart) {
            pid_t pid = fork();
            switch (pid) {
            case -1: /* handle error */ exit(EXIT_FAILURE);
            case 0: exit(mainApp());
            default: break;
            }
            pid_t child = wait(&status);
            assert(child == pid);
            restart = check_status(status);
        }
        /*...cleanup...*/
        return 0;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a program that ran in iOS 2.0 and now am making some
I have done one program that allow user can listen to the music via
I have a program and as it's done now, it has a data directory
I almost done my coding for a specific program i have. I just need
Have done some research and found some stuff that may be helpful. I would
I want to write my first assembly program. I have done some programs on
I have done some applet program in java, which will change the color of
I have done some tests with QueryPerformanceCounter and got strange results. It seems that
I have done some really serious refactoring of my text editor. Now there is
I am working on some test program for SpringData MongoDB , I have done

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.