Re: Killing process started by system()?



carsonbj@xxxxxxxxx wrote:
Is there anyway to kill a process that has been started by the system()
function?


At the bottom, all processes will be created using the same mechansim: a fork()(or newer: clone()?) system call. There is no difference between you typing "ls" at the shell prompt and your program executing "system("ls");". AAMOF: "system() executes a command specified in string by calling /bin/sh -c string" (from "man 3 system").

So, you can just "kill <pid>" or "kill -9 <pid>" to kill that process.

If you can't, then there must be another reason, not related to the fact that the process was started using system(3), e.g. the process hangs in D state or it's not running under your UID. See the output of ps.
--
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett

.