OpenQNX :: The QNX Community Portal

Oct 12, 2008 - 06:05 PM
Google
  Web openqnx.com   
     Create an account Home · Submit News · QNX Forums · QNX Download · Search   
_
Main Menu
Who's Online
There are 18 unlogged users and 0 registered users online.

You can log-in or register for a user account here.

Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
sabtain
Post subject: self monitoring process  PostPosted: Nov 16, 2007 - 06:33 PM
Guest





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??
 
   
Reply with quote Back to top
sabtain
Post subject: Re: self monitoring process  PostPosted: Nov 16, 2007 - 08:23 PM
Guest





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...
Quote:
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??
 
   
Reply with quote Back to top
maschoen
Post subject: RE: Re: self monitoring process  PostPosted: Nov 18, 2007 - 01:16 AM
QNX Master


Joined: Jun 25, 2003
Posts: 1099

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.
 
 View user's profile Send private message Send e-mail Visit poster's website  
Reply with quote Back to top
Joan Baucells
Post subject: Re: self monitoring process  PostPosted: Nov 19, 2007 - 07:52 AM
Guest





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:

Quote:
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??
 
   
Reply with quote Back to top
sabtain
Post subject: Re: Re: self monitoring process  PostPosted: Nov 19, 2007 - 05:42 PM
Guest





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...
Quote:
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.
 
   
Reply with quote Back to top
Mario Charest
Post subject: Re: self monitoring process  PostPosted: Nov 19, 2007 - 06:23 PM
Guest





"Joan Baucells" <joan_baucells@NoSpam.es> wrote in message
news:474140C8.DC16455C@NoSpam.es...
Quote:
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!

Quote:

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??
 
   
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
All logos and trademarks in this site are property of their respective owners. The comments are property of their posters.
Powered by OpenQNX: The QNX Community Portal Site
QNX and the QNX logo are registered trademarks of QNX Software Systems.