Is there a command to get a childs process PID and kill it?
I am using :
pid = getpid(); this one kills the main program.
or
pid = getppid(); this one kills all of the windows.
Is there a command to get a childs process PID and kill it?
I am using :
pid = getpid(); this one kills the main program.
or
pid = getppid(); this one kills all of the windows.
Which platform???
For Win32 ypou could use TerminateProcess()
Unix platform
use the kill() function then - section 2 of the manual
this is in the main program
system("./man&");
which executes another child program.
how do I kill that program from the main program?
I am using this but it kills all the windows or the main program. I just want to kill the child process.
int pid;
pid = getppid();
kill(pid,1);
Thanks again,
Then use fork() and execl() for creating the process, and you'll have the process ID directly to hand
Something like this
Code:int pid; pid = fork(); if ( pid == 0 ) { execl( "/bin/man", "/bin/man", NULL ); } /* here, man will be running with process ID pid */