summaryrefslogtreecommitdiffstats
path: root/usr/utils/kill.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/utils/kill.c')
-rw-r--r--usr/utils/kill.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/usr/utils/kill.c b/usr/utils/kill.c
new file mode 100644
index 0000000..188f1b5
--- /dev/null
+++ b/usr/utils/kill.c
@@ -0,0 +1,33 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <string.h>
+
+char *progname;
+
+static __noreturn usage(void)
+{
+ fprintf(stderr, "Usage: %s pid\n", progname);
+ exit(1);
+}
+int main(int argc, char *argv[])
+{
+ long pid;
+ char *endp;
+
+ progname = argv[0];
+ if (argc != 2)
+ usage();
+
+ pid = strtol(argv[1], &endp, 10);
+ if (*endp != '\0') {
+ perror("pid");
+ usage();
+ }
+
+ if (kill(pid, SIGTERM) == -1) {
+ perror("kill");
+ exit(-1);
+ }
+ exit(0);
+}