2021-06-12 23:34:41 +02:00
|
|
|
|
2021-04-02 00:06:12 +02:00
|
|
|
int cmd_pkill(char param[])
|
|
|
|
{
|
2021-06-12 23:34:41 +02:00
|
|
|
int i = 1, n = 0; int process_count = 0;
|
|
|
|
char *buf1k = NULL;
|
2021-04-02 00:06:12 +02:00
|
|
|
unsigned PID=0;
|
|
|
|
|
|
|
|
if(!strlen(param)){
|
2021-06-12 23:34:41 +02:00
|
|
|
printf(CMD_PKILL_HELP);
|
2021-04-02 00:06:12 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
buf1k = malloc(1024);
|
2021-06-12 23:34:41 +02:00
|
|
|
if (buf1k == NULL){
|
2021-04-02 00:06:12 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2021-06-12 23:34:41 +02:00
|
|
|
while (i != n) {
|
2021-04-02 00:06:12 +02:00
|
|
|
n = kol_process_info(i, buf1k);
|
|
|
|
if(!strnicmp(buf1k+10, param, 10)){
|
|
|
|
memcpy(&PID, buf1k+30 ,sizeof(unsigned));
|
|
|
|
if(kol_process_kill_pid(PID)){
|
2021-06-12 23:34:41 +02:00
|
|
|
printf(CMD_PKILL_NOT_KILL, PID);
|
2021-04-02 00:06:12 +02:00
|
|
|
}else{
|
2021-06-12 23:34:41 +02:00
|
|
|
printf(CMD_PKILL_KILL, PID);
|
2021-04-02 00:06:12 +02:00
|
|
|
}
|
|
|
|
process_count++;
|
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!process_count){
|
2021-06-12 23:34:41 +02:00
|
|
|
printf(CMD_PKILL_NOT_FOUND);
|
2021-04-02 00:06:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
free(buf1k);
|
|
|
|
return TRUE;
|
|
|
|
}
|