lobase

Linux port of OpenBSDs userland.
Log | Files | Refs | README

commit e29c84fb53799057196967dfa2716506fb771528
parent b17daf4b7842b0bdc03d4c032248a3ae204b78a6
Author: Duncaen <mail@duncano.de>
Date:   Wed, 24 May 2017 03:00:59 +0200

bin/kill: update to OPENBSD_6_1

Diffstat:
bin/kill/kill.1 | 7++++---
bin/kill/kill.c | 35++++++++++++++++++-----------------
2 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/bin/kill/kill.1 b/bin/kill/kill.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: kill.1,v 1.38 2015/01/16 21:31:27 millert Exp $ +.\" $OpenBSD: kill.1,v 1.39 2016/08/16 18:51:25 schwarze Exp $ .\" $NetBSD: kill.1,v 1.8 1995/09/07 06:30:26 jtc Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 @@ -33,7 +33,7 @@ .\" .\" @(#)kill.1 8.2 (Berkeley) 4/28/95 .\" -.Dd $Mdocdate: January 16 2015 $ +.Dd $Mdocdate: August 16 2016 $ .Dt KILL 1 .Os .Sh NAME @@ -180,4 +180,5 @@ though with a different syntax. A .Nm command appeared in -.At v3 . +.At v3 +in section 8 of the manual. diff --git a/bin/kill/kill.c b/bin/kill/kill.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kill.c,v 1.13 2015/10/10 21:15:25 doug Exp $ */ +/* $OpenBSD: kill.c,v 1.14 2017/03/29 22:40:15 millert Exp $ */ /* $NetBSD: kill.c,v 1.11 1995/09/07 06:30:27 jtc Exp $ */ /* @@ -33,6 +33,7 @@ #include <ctype.h> #include <err.h> #include <errno.h> +#include <limits.h> #include <signal.h> #include <stdio.h> #include <stdlib.h> @@ -50,7 +51,7 @@ int main(int argc, char *argv[]) { int errors, numsig, pid; - char *ep; + const char *errstr; if (pledge("stdio proc", NULL) == -1) err(1, "pledge"); @@ -70,14 +71,13 @@ main(int argc, char *argv[]) if (argc == 1) { if (!isdigit((unsigned char)**argv)) usage(); - numsig = strtol(*argv, &ep, 10); - if (*ep) + numsig = strtonum(*argv, 1, NSIG + 127, &errstr); + if (errstr != NULL) { + if (errno == ERANGE) + nosig(*argv); errx(1, "illegal signal number: %s", *argv); - if (numsig >= 128) - numsig -= 128; - if (numsig <= 0 || numsig >= NSIG) - nosig(*argv); - printf("%s\n", strsignal(numsig)); + } + printf("%s\n", sys_signame[numsig & 127]); exit(0); } printsignals(stdout); @@ -105,11 +105,12 @@ main(int argc, char *argv[]) if ((numsig = signame_to_signum(*argv)) < 0) nosig(*argv); } else if (isdigit((unsigned char)**argv)) { - numsig = strtol(*argv, &ep, 10); - if (*ep) + numsig = strtonum(*argv, 0, NSIG - 1, &errstr); + if (errstr != NULL) { + if (errno == ERANGE) + nosig(*argv); errx(1, "illegal signal number: %s", *argv); - if (numsig < 0 || numsig >= NSIG) - nosig(*argv); + } } else nosig(*argv); } @@ -120,8 +121,8 @@ main(int argc, char *argv[]) usage(); for (errors = 0; argc; argc--, argv++) { - pid = strtol(*argv, &ep, 10); - if (!**argv || *ep) { + pid = strtonum(*argv, -INT_MAX, INT_MAX, &errstr); + if (errstr != NULL) { warnx("illegal process id: %s", *argv); errors = 1; } else if (kill(pid, numsig) == -1) { @@ -141,7 +142,7 @@ signame_to_signum(char *sig) if (!strncasecmp(sig, "sig", 3)) sig += 3; for (n = 1; n < NSIG; n++) { - if (!strcasecmp(strsignal(n), sig)) + if (!strcasecmp(sys_signame[n], sig)) return (n); } return (-1); @@ -162,7 +163,7 @@ printsignals(FILE *fp) int n; for (n = 1; n < NSIG; n++) { - (void)fprintf(fp, "%s", strsignal(n)); + (void)fprintf(fp, "%s", sys_signame[n]); if (n == (NSIG / 2) || n == (NSIG - 1)) (void)fprintf(fp, "\n"); else