In short, I'm trying to kill a process in the middle of its run. For example, I have a binary file test which runs something similar like: 
while (true) {
  // Do something
}
I'm calling this binary file via the system() function in C++ like so: 
const char* cmd = "test";
system(cmd);
Now is there any way for me to kill the process without having to manually go into the Linux shell? I have been able to manually simulate this function by running testand then typing ctrl+c into the shell. Thanks in advance :)