File: kill.c

package info (click to toggle)
klibc 2.0.14-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,204 kB
  • sloc: ansic: 48,657; asm: 2,204; perl: 693; makefile: 220; sh: 177
file content (33 lines) | stat: -rw-r--r-- 464 bytes parent folder | download | duplicates (10)
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);
}