I'm running a C++ program under LINUX.
From my program's code I'm calling another program with a system() call:
system("calledProgram opt1 opt2 ... opt_n");
But this calledProgram runs with multiple processes (with a specific names, say p1, p2, p3, p4).
How can find and kill these processes when my program is being killed externally by the user.
Here (How to kill process in c++, knowing only part of its name) described how to find processes with a specific name and kill them.
But what if user runs the program with the same options from different directories. Should I check for the running directory also to find correct processes?
Is there another (better) way to kill those child processes?
PS: When I'm running calledProgram from the cmd line, and then, killing it by ctrl+c, its processes are not being killed automatically.