I am using a system() to call an executable program(A server) . Now after a certain time I want to terminate this program from my c program itself. Does anyone know how to do this?
OS running:(http://rcn-ee.net/deb/rootfs/precise/ubuntu-12.04-r4-minimal-armhf-2012-07-16.tar.xz)
I am using a system() to call an executable program(A server) . Now after
Share
The best way to do this is to use a function that gives you more control over the resulting process than
system()does. However, this would be platform specific.For Windows, use
CreateProcess()which returns aHANDLEwhich you can use later inTerminateProcess()to kill the process.For Unix, use
fork()andexec()which gives you the pid of the child process, which you can use later inkill()to kill the process.