timeout: fix arguments to match coreutils
Was: timeout [-t SECS] [-s SIG] PROG ARGS Is: timeout [-s SIG] SECS PROG ARGS function old new delta timeout_main 312 319 +7 packed_usage 32882 32858 -24 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 7/-24) Total: -17 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
4c20d9f2b0
commit
c9720a761e
@ -39,10 +39,10 @@
|
|||||||
//kbuild:lib-$(CONFIG_TIMEOUT) += timeout.o
|
//kbuild:lib-$(CONFIG_TIMEOUT) += timeout.o
|
||||||
|
|
||||||
//usage:#define timeout_trivial_usage
|
//usage:#define timeout_trivial_usage
|
||||||
//usage: "[-t SECS] [-s SIG] PROG ARGS"
|
//usage: "[-s SIG] SECS PROG ARGS"
|
||||||
//usage:#define timeout_full_usage "\n\n"
|
//usage:#define timeout_full_usage "\n\n"
|
||||||
//usage: "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n"
|
//usage: "Runs PROG. Sends SIG to it if it is not gone in SECS seconds.\n"
|
||||||
//usage: "Defaults: SECS: 10, SIG: TERM."
|
//usage: "Default SIG: TERM."
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
@ -52,8 +52,7 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
int signo;
|
int signo;
|
||||||
int status;
|
int status;
|
||||||
int parent = 0;
|
int parent = 0;
|
||||||
unsigned timeout;
|
int timeout;
|
||||||
const char *timeout_s = "10";
|
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
#if !BB_MMU
|
#if !BB_MMU
|
||||||
char *sv1, *sv2;
|
char *sv1, *sv2;
|
||||||
@ -64,12 +63,18 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
|
|
||||||
/* -t SECONDS; -p PARENT_PID */
|
/* -t SECONDS; -p PARENT_PID */
|
||||||
/* '+': stop at first non-option */
|
/* '+': stop at first non-option */
|
||||||
getopt32(argv, "+s:t:" USE_FOR_NOMMU("p:+"), &opt_s, &timeout_s, &parent);
|
getopt32(argv, "+s:" USE_FOR_NOMMU("p:+"), &opt_s, &parent);
|
||||||
/*argv += optind; - no, wait for bb_daemonize_or_rexec! */
|
/*argv += optind; - no, wait for bb_daemonize_or_rexec! */
|
||||||
|
|
||||||
signo = get_signum(opt_s);
|
signo = get_signum(opt_s);
|
||||||
if (signo < 0)
|
if (signo < 0)
|
||||||
bb_error_msg_and_die("unknown signal '%s'", opt_s);
|
bb_error_msg_and_die("unknown signal '%s'", opt_s);
|
||||||
timeout = parse_duration_str((char*)timeout_s);
|
|
||||||
|
if (!argv[optind])
|
||||||
|
bb_show_usage();
|
||||||
|
timeout = parse_duration_str(argv[optind++]);
|
||||||
|
if (!argv[optind]) /* no PROG? */
|
||||||
|
bb_show_usage();
|
||||||
|
|
||||||
/* We want to create a grandchild which will watch
|
/* We want to create a grandchild which will watch
|
||||||
* and kill the grandparent. Other methods:
|
* and kill the grandparent. Other methods:
|
||||||
@ -77,12 +82,10 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
* (example: "tcpsvd 0.0.0.0 1234 timeout service_prog" -
|
* (example: "tcpsvd 0.0.0.0 1234 timeout service_prog" -
|
||||||
* it's better if service_prog is a child of tcpsvd!),
|
* it's better if service_prog is a child of tcpsvd!),
|
||||||
* making child watch parent results in programs having
|
* making child watch parent results in programs having
|
||||||
* unexpected children. */
|
* unexpected children. */
|
||||||
|
|
||||||
if (parent) /* we were re-execed, already grandchild */
|
if (parent) /* we were re-execed, already grandchild */
|
||||||
goto grandchild;
|
goto grandchild;
|
||||||
if (!argv[optind]) /* no PROG? */
|
|
||||||
bb_show_usage();
|
|
||||||
|
|
||||||
#if !BB_MMU
|
#if !BB_MMU
|
||||||
sv1 = argv[optind];
|
sv1 = argv[optind];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user