How to detect a running program and restart it if necessary

2007-10-22 04:36:03 AM
How can you tell if a program is running and stop it and restart it?
I am writing a program that must start before another program it
depends on starts, and must stop it and restart it if it is already
What calls are required for that?