1 /* kill - send a signal to a process Author: Adri Koppes */
10 int main(int argc
, char **argv
);
13 /* Table of signal names. */
42 { "WINCH", SIGWINCH
},
44 { "VTALRM", SIGVTALRM
},
54 int ex
= 0, sig
= SIGTERM
;
62 if (argc
> 1 && argv
[1][0] == '-') {
64 for (snp
= signames
; snp
->name
!= NULL
; snp
++) { /* symbolic? */
65 if (strcmp(snp
->name
, argv
[1] + 1) == 0) {
70 if (sig
< 0) { /* numeric? */
71 ul
= strtoul(argv
[1] + 1, &end
, 10);
72 if (end
== argv
[1] + 1 || *end
!= 0 || ul
>= _NSIG
) usage();
79 sigemptyset(&sa
.sa_mask
);
80 sa
.sa_handler
= SIG_IGN
; /* try not to kill yourself */
81 (void) sigaction(sig
, &sa
, (struct sigaction
*) NULL
);
83 for (doit
= 0; doit
<= 1; doit
++) {
84 for (i
= 1; i
< argc
; i
++) {
85 l
= strtoul(argv
[i
], &end
, 10);
86 if (end
== argv
[i
] || *end
!= 0 || (pid_t
) l
!= l
) usage();
88 if (doit
&& kill(proc
, sig
) < 0) {
89 fprintf(stderr
, "kill: %d: %s\n",
90 proc
, strerror(errno
));
100 fprintf(stderr
, "Usage: kill [-sig] pid\n");