blob: 4d0e47999c261c7e15289973c8d48c802fdbd006 [file] [log] [blame]
The Android Open Source Projectdd7bc332009-03-03 19:32:55 -08001#include <stdio.h>
2#include <stdlib.h>
3#include <errno.h>
4
5#include <sys/types.h>
6#include <signal.h>
7
8int kill_main(int argc, char **argv)
9{
10 int sig = SIGTERM;
11 int result = 0;
12
13 argc--;
14 argv++;
15
16 if(argc >= 2 && argv[0][0] == '-'){
17 sig = atoi(argv[0] + 1);
18 argc--;
19 argv++;
20 }
21
22 while(argc > 0){
23 int pid = atoi(argv[0]);
24 int err = kill(pid, sig);
25 if (err < 0) {
26 result = err;
27 fprintf(stderr, "could not kill pid %d: %s\n", pid, strerror(errno));
28 }
29
30 argc--;
31 argv++;
32 }
33
34 return result;
35}