summaryrefslogtreecommitdiffstats
path: root/usr/utils/kill.c
blob: 188f1b5b6880d567eef9cb6e6acd35d3bbc9edc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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);
}