blob: 4d0e47999c261c7e15289973c8d48c802fdbd006 [file] [log] [blame]
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <signal.h>
int kill_main(int argc, char **argv)
{
int sig = SIGTERM;
int result = 0;
argc--;
argv++;
if(argc >= 2 && argv[0][0] == '-'){
sig = atoi(argv[0] + 1);
argc--;
argv++;
}
while(argc > 0){
int pid = atoi(argv[0]);
int err = kill(pid, sig);
if (err < 0) {
result = err;
fprintf(stderr, "could not kill pid %d: %s\n", pid, strerror(errno));
}
argc--;
argv++;
}
return result;
}