Skip navigation.
Home
The QNX Community Portal

View topic - self monitoring process

self monitoring process

Read-only archive of qnx.rtos (Writing resources managers, and general discussion around the QNX Neutrino RTOS) at inn.qnx.com

self monitoring process

Postby sabtain » Fri Nov 16, 2007 6:33 pm

I am designing an application that is using HAM to monitor other processes
on the system. This application must also monitor itself so that if it
terminates due to a fault, it restarts itself. The basic design is as
follows

1. application on startup forks and attached to HAM
2. parent monitors other processes
3. child monitor parent
4. if parent fails, child repeat step 1-3.

I know i have to use fork. what I want suggestions on is how to go about
step 4 when the parent dies. That is when HAM informs the child that the
parent is dead, how to proceed with reforking and restarting the entire
process again. Can I somehow make a recursive call??
sabtain
 

Re: self monitoring process

Postby sabtain » Fri Nov 16, 2007 8:23 pm

It will be helpful If I can find a way to write a custom action for the
condition in HAM.


"sabtain" <khansx@aecl.ca> wrote in message news:fhknit$o4a$1@inn.qnx.com...
I am designing an application that is using HAM to monitor other processes
on the system. This application must also monitor itself so that if it
terminates due to a fault, it restarts itself. The basic design is as
follows

1. application on startup forks and attached to HAM
2. parent monitors other processes
3. child monitor parent
4. if parent fails, child repeat step 1-3.

I know i have to use fork. what I want suggestions on is how to go about
step 4 when the parent dies. That is when HAM informs the child that the
parent is dead, how to proceed with reforking and restarting the entire
process again. Can I somehow make a recursive call??
sabtain
 

RE: Re: self monitoring process

Postby maschoen » Sun Nov 18, 2007 1:16 am

I think you just need a loop, something like this.

Loop
Fork, Parent monitors 4 processes, child monitors parent (Actually I think it might be easier the other way around
Wait for parent to die
End Loop

You might want to be careful that you don't fork too often. If something crucial prevents either the fork from working, or
the forked process from running, you don't want continual calls to fork. This can really hose up a system that is already
sick.
maschoen
QNX Master
 
Posts: 2640
Joined: Wed Jun 25, 2003 5:18 pm

Re: self monitoring process

Postby Joan Baucells » Mon Nov 19, 2007 7:52 am

Sometimes we've used a shellscript with an infinite loop (while true ...)
Inside the loop you can call your program
While your program is active the infinite loop is waiting for the end of the
launched program
If your program dies the loop will execute next iteration restarting your
program.
You can add an sleep in the loop to prevent collapsing system if the program
fails continously

To stop your program you have to first stop the shellscript with the infinite
loop (We use kill command to do that)

sabtain wrote:

I am designing an application that is using HAM to monitor other processes
on the system. This application must also monitor itself so that if it
terminates due to a fault, it restarts itself. The basic design is as
follows

1. application on startup forks and attached to HAM
2. parent monitors other processes
3. child monitor parent
4. if parent fails, child repeat step 1-3.

I know i have to use fork. what I want suggestions on is how to go about
step 4 when the parent dies. That is when HAM informs the child that the
parent is dead, how to proceed with reforking and restarting the entire
process again. Can I somehow make a recursive call??
Joan Baucells
 

Re: Re: self monitoring process

Postby sabtain » Mon Nov 19, 2007 5:42 pm

why can I not call the main() recursively in the child process after it
detects the parent failure?? I need to fork everytime the parent proces
fails so i can always have 2 copies of the process running.

Thanks

Sabain

"maschoen" <maschoen@pobox-dot-com.no-spam.invalid> wrote in message
news:fho63s$5nn$2@inn.qnx.com...
I think you just need a loop, something like this.

Loop
Fork, Parent monitors 4 processes, child monitors parent (Actually
I think it might be easier the other way around
Wait for parent to die
End Loop

You might want to be careful that you don't fork too often. If
something crucial prevents either the fork from working, or
the forked process from running, you don't want continual calls to
fork. This can really hose up a system that is already
sick.
sabtain
 

Re: self monitoring process

Postby Mario Charest » Mon Nov 19, 2007 6:23 pm

"Joan Baucells" <joan_baucells@NoSpam.es> wrote in message
news:474140C8.DC16455C@NoSpam.es...
Sometimes we've used a shellscript with an infinite loop (while true ...)
Inside the loop you can call your program
While your program is active the infinite loop is waiting for the end of
the
launched program
If your program dies the loop will execute next iteration restarting your
program.
You can add an sleep in the loop to prevent collapsing system if the
program
fails continously

tinit can do that for you!

To stop your program you have to first stop the shellscript with the
infinite
loop (We use kill command to do that)

sabtain wrote:

I am designing an application that is using HAM to monitor other
processes
on the system. This application must also monitor itself so that if it
terminates due to a fault, it restarts itself. The basic design is as
follows

1. application on startup forks and attached to HAM
2. parent monitors other processes
3. child monitor parent
4. if parent fails, child repeat step 1-3.

I know i have to use fork. what I want suggestions on is how to go about
step 4 when the parent dies. That is when HAM informs the child that the
parent is dead, how to proceed with reforking and restarting the entire
process again. Can I somehow make a recursive call??
Mario Charest
 


Return to qnx.rtos

Who is online

Users browsing this forum: No registered users and 3 guests