I'm writing a program that open a .txt file by vim and whenever i press CTRL+C the process will be killed. But the thing is i can't find the process's pid that i've just created and kill it. Can anybody help me?
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
void ctrl_C(int sig){
system("kill -9 $(pidof id)");
printf("\n You pressed Ctrl + C,Good Bye \n");
exit(0);
}
int main(){
printf("I am Programmer \n");
pid_t id = system("gnome-terminal -- vi abcd.txt");
signal(SIGINT,ctrl_C);
while(1){}
}