Excuting a program within a C Program

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
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top