From 93fdf652ed238223145bc6c14fdca9ab3d232d43 Mon Sep 17 00:00:00 2001 From: Quazar2 Date: Mon, 9 Mar 2026 21:37:03 +0100 Subject: [PATCH] Added main.c containing the tool source --- main.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 main.c diff --git a/main.c b/main.c new file mode 100644 index 0000000..fe762b6 --- /dev/null +++ b/main.c @@ -0,0 +1,38 @@ +#include +#include +#include + +int main(int argc, char** argv){ + char buff[1028]; + char p_name[1028]; + int* PIDs = malloc(100*sizeof(int)); + if(argc<2){ + printf("Usage :\nfirst parameter is the name of the program to be killed. it'll then ask you which one that matches do you want to kill\n"); + } + else if(argv[1][0]=='-'){ + switch(argv[1][1]){ + case 'h': + printf("Usage :\nfirst parameter is the name of the program to be killed. it'll then ask you which one that matches do you want to kill\n"); + break; + case 'v': + printf("v0.0\n"); + default: + printf("Unknown option : -%c\n",argv[1][1]); + } + } + else{ + char* cmd= malloc(18+strlen(argv[1])); + sprintf(cmd,"ps aux | grep %s",argv[1]); + FILE* c = popen(cmd,"r"); + int i=0; + printf("which one do you want to kill ?\n"); + while(fgets(buff,1028,c)!=NULL){ + sscanf(buff,"%s\t%d\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s",p_name,PIDs+i,p_name,p_name,p_name,p_name,p_name,p_name,p_name,p_name,p_name); + printf("%d : %s\n",i,p_name); + i++; + } + scanf("%d",&i); + sprintf(cmd,"/usr/bin/kill -SIGKILL %d",PIDs[i]); + system(cmd); + } +}