Magellan Linux

Contents of /trunk/mkinitrd-magellan/klibc/usr/utils/kill.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 815 - (show annotations) (download)
Fri Apr 24 18:32:46 2009 UTC (15 years, 1 month ago) by niro
File MIME type: text/plain
File size: 464 byte(s)
-updated to klibc-1.5.15
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <signal.h>
4 #include <string.h>
5
6 char *progname;
7
8 static __noreturn usage(void)
9 {
10 fprintf(stderr, "Usage: %s pid\n", progname);
11 exit(1);
12 }
13 int main(int argc, char *argv[])
14 {
15 long pid;
16 char *endp;
17
18 progname = argv[0];
19 if (argc != 2)
20 usage();
21
22 pid = strtol(argv[1], &endp, 10);
23 if (*endp != '\0') {
24 perror("pid");
25 usage();
26 }
27
28 if (kill(pid, SIGTERM) == -1) {
29 perror("kill");
30 exit(-1);
31 }
32 exit(0);
33 }