POSIX is addint this utility in Issue 8 (whenever it appears). However
they do not specify "long" options (ever). The --preserve and --foreground options in this utility had no short form, so they "invented" -p and -f so only standard form one char options needed to be specified. Change the opt processing here so -p == --preserve and -f == --foreground so we support the options POSIX will specify. No other changes here, just adding those alternates for the options.
This commit is contained in:
parent
e311a492a7
commit
f2d4de93b1
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: timeout.1,v 1.4 2016/10/13 06:22:26 dholland Exp $
|
||||
.\" $NetBSD: timeout.1,v 1.5 2022/12/13 13:25:36 kre Exp $
|
||||
.\"
|
||||
.\" Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org>
|
||||
.\" All rights reserved.
|
||||
|
@ -26,7 +26,7 @@
|
|||
.\"
|
||||
.\" $FreeBSD: head/usr.bin/timeout/timeout.1 268861 2014-07-18 22:56:59Z bapt $
|
||||
.\"
|
||||
.Dd July 19, 2014
|
||||
.Dd December 13, 2022
|
||||
.Dt TIMEOUT 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
|
@ -35,9 +35,9 @@
|
|||
.Sh SYNOPSIS
|
||||
.Nm
|
||||
.Op Fl Fl signal Ar sig | Fl s Ar sig
|
||||
.Op Fl Fl preserve-status
|
||||
.Op Fl Fl preserve-status | Fl p
|
||||
.Op Fl Fl kill-after Ar time | Fl k Ar time
|
||||
.Op Fl Fl foreground
|
||||
.Op Fl Fl foreground | Fl f
|
||||
.Ao Ar duration Ac
|
||||
.Ao Ar command Ac
|
||||
.Ao Ar args ... Ac
|
||||
|
@ -56,11 +56,11 @@ By default,
|
|||
.Dv SIGTERM
|
||||
is sent.
|
||||
.Bl -tag -width "-k time, --kill-after time"
|
||||
.It Fl Fl preserve-status
|
||||
.It Fl p , Fl Fl preserve-status
|
||||
Always exits with the same status as
|
||||
.Ar command
|
||||
even if it times out.
|
||||
.It Fl Fl foreground
|
||||
.It Fl f , Fl Fl foreground
|
||||
Do not propagate timeout to the
|
||||
.Ar command
|
||||
children.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: timeout.c,v 1.4 2014/08/05 08:20:02 christos Exp $ */
|
||||
/* $NetBSD: timeout.c,v 1.5 2022/12/13 13:25:36 kre Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2014 Baptiste Daroussin <bapt@FreeBSD.org>
|
||||
|
@ -32,7 +32,7 @@
|
|||
#if 0
|
||||
__FBSDID("$FreeBSD: head/usr.bin/timeout/timeout.c 268763 2014-07-16 13:52:05Z bapt $");
|
||||
#else
|
||||
__RCSID("$NetBSD: timeout.c,v 1.4 2014/08/05 08:20:02 christos Exp $");
|
||||
__RCSID("$NetBSD: timeout.c,v 1.5 2022/12/13 13:25:36 kre Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -212,20 +212,27 @@ main(int argc, char **argv)
|
|||
pgid = -1;
|
||||
|
||||
const struct option longopts[] = {
|
||||
{ "preserve-status", no_argument, &preserve, 1 },
|
||||
{ "foreground", no_argument, &foreground, 1 },
|
||||
{ "preserve-status", no_argument, NULL, 'p'},
|
||||
{ "foreground", no_argument, NULL, 'f'},
|
||||
{ "kill-after", required_argument, NULL, 'k'},
|
||||
{ "signal", required_argument, NULL, 's'},
|
||||
{ "help", no_argument, NULL, 'h'},
|
||||
{ NULL, 0, NULL, 0 }
|
||||
};
|
||||
|
||||
while ((ch = getopt_long(argc, argv, "+k:s:h", longopts, NULL)) != -1) {
|
||||
while ((ch =
|
||||
getopt_long(argc, argv, "+fk:ps:h", longopts, NULL)) != -1) {
|
||||
switch (ch) {
|
||||
case 'f':
|
||||
foreground = 1;
|
||||
break;
|
||||
case 'k':
|
||||
do_second_kill = true;
|
||||
second_kill = parse_duration(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
preserve = 1;
|
||||
break;
|
||||
case 's':
|
||||
killsig = parse_signal(optarg);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue