Some time ago I needed to write c++ code to kill some process. In my main program I run large CAE-system package with system(\"...\") with different filename strings on inpu
You don't have to open a shell to kill a process. Just use the "kill" function:
#include
#include
int kill(pid_t pid, int sig);
http://linux.die.net/man/2/kill
To find a process to kill read the following directory:
/proc/####/cmdline
Where #### is the number of any running process id. So the code roughly would be to read the /proc directory and list out all the numerical directories, these are the current running processes, and you find the name of the command that spawned that process in the "cmdline" file in that directory. You can then use a regular expression, or a string comparison to identify processes to kill.