From c2c0cfbeb6f07fa3257a60760d5c8a5382cee6e9 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Tue, 23 May 2023 10:57:56 +0100 Subject: timeout: code shrink In the win32 code the 'parent' variable is always zero. It's also used as the pid to be killed when the child process survives the initial kill attempt. Although this works as intended there's no need for the 'parent' variable. Saves 16 bytes. --- coreutils/timeout.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'coreutils/timeout.c') diff --git a/coreutils/timeout.c b/coreutils/timeout.c index c8171ec54..3565c005d 100644 --- a/coreutils/timeout.c +++ b/coreutils/timeout.c @@ -97,11 +97,11 @@ int timeout_main(int argc UNUSED_PARAM, char **argv) int signo; #if !ENABLE_PLATFORM_MINGW32 int status; + int parent = 0; #else intptr_t ret; DWORD status = EXIT_SUCCESS; #endif - int parent = 0; int timeout; int kill_timeout; pid_t pid; @@ -119,7 +119,11 @@ int timeout_main(int argc UNUSED_PARAM, char **argv) /* -t SECONDS; -p PARENT_PID */ /* '+': stop at first non-option */ +#if !ENABLE_PLATFORM_MINGW32 getopt32(argv, "+s:k:" USE_FOR_NOMMU("p:+"), &opt_s, &opt_k, &parent); +#else + getopt32(argv, "+s:k:", &opt_s, &opt_k); +#endif /*argv += optind; - no, wait for bb_daemonize_or_rexec! */ signo = get_signum(opt_s); @@ -212,7 +216,7 @@ int timeout_main(int argc UNUSED_PARAM, char **argv) if (kill_timeout > 0) { if (timeout_wait(kill_timeout, child, &status)) goto finish; - kill(parent, SIGKILL); + kill(pid, SIGKILL); status = 137; } finish: -- cgit v1.2.3-55-g6feb