Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/timeout POSIX is addint this utility in Issue 8 (whe...



details:   https://anonhg.NetBSD.org/src/rev/9fbe3391c759
branches:  trunk
changeset: 372621:9fbe3391c759
user:      kre <kre%NetBSD.org@localhost>
date:      Tue Dec 13 13:25:36 2022 +0000

description:
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.

diffstat:

 usr.bin/timeout/timeout.1 |  12 ++++++------
 usr.bin/timeout/timeout.c |  17 ++++++++++++-----
 2 files changed, 18 insertions(+), 11 deletions(-)

diffs (93 lines):

diff -r f39af8019e45 -r 9fbe3391c759 usr.bin/timeout/timeout.1
--- a/usr.bin/timeout/timeout.1 Tue Dec 13 12:43:32 2022 +0000
+++ b/usr.bin/timeout/timeout.1 Tue Dec 13 13:25:36 2022 +0000
@@ -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@localhost>
 .\" 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 @@
 .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.
diff -r f39af8019e45 -r 9fbe3391c759 usr.bin/timeout/timeout.c
--- a/usr.bin/timeout/timeout.c Tue Dec 13 12:43:32 2022 +0000
+++ b/usr.bin/timeout/timeout.c Tue Dec 13 13:25:36 2022 +0000
@@ -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@localhost>
@@ -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 @@
        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;



Home | Main Index | Thread Index | Old Index