- Joined
- Mar 9, 2010
- Messages
- 1
- Reaction score
- 0
Hey guys,
Now I understand that I should use the system call:
system("processID")
to execute a program.
However my question is, if that program is server based I want that program to never stop running.
Basically I want to make sure my server application (we'll say "example.c") is relaunched if an unexpected error takes place.
Sort of like a watchdog in my main that checks if the application (example.c) is running and if it is not it is launched.
I was thinking I could use the fork() call to get the PID for the running check of the process.
Here is my current example:
void main(){
// Launch example.c Is this where a system("example.c") would take place?
while(1){
// Is example.c running? Is this where a PID check would take place?
// If not launch
}
}
Would this work for my current issue?
thanks
Now I understand that I should use the system call:
system("processID")
to execute a program.
However my question is, if that program is server based I want that program to never stop running.
Basically I want to make sure my server application (we'll say "example.c") is relaunched if an unexpected error takes place.
Sort of like a watchdog in my main that checks if the application (example.c) is running and if it is not it is launched.
I was thinking I could use the fork() call to get the PID for the running check of the process.
Here is my current example:
void main(){
// Launch example.c Is this where a system("example.c") would take place?
while(1){
// Is example.c running? Is this where a PID check would take place?
// If not launch
}
}
Would this work for my current issue?
thanks
Last edited: