aboutsummaryrefslogtreecommitdiff
path: root/coreutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-05-23 10:57:56 +0100
committerRon Yorston <rmy@pobox.com>2023-05-23 10:57:56 +0100
commitc2c0cfbeb6f07fa3257a60760d5c8a5382cee6e9 (patch)
tree24c2d1673884937ef5c2ea03a572b1952567e1b3 /coreutils
parenta0ed5a7ceaf4636eab0bb66b523a9eaf437acbe8 (diff)
downloadbusybox-w32-c2c0cfbeb6f07fa3257a60760d5c8a5382cee6e9.tar.gz
busybox-w32-c2c0cfbeb6f07fa3257a60760d5c8a5382cee6e9.tar.bz2
busybox-w32-c2c0cfbeb6f07fa3257a60760d5c8a5382cee6e9.zip
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.
Diffstat (limited to 'coreutils')
-rw-r--r--coreutils/timeout.c8
1 files changed, 6 insertions, 2 deletions
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)
97 int signo; 97 int signo;
98#if !ENABLE_PLATFORM_MINGW32 98#if !ENABLE_PLATFORM_MINGW32
99 int status; 99 int status;
100 int parent = 0;
100#else 101#else
101 intptr_t ret; 102 intptr_t ret;
102 DWORD status = EXIT_SUCCESS; 103 DWORD status = EXIT_SUCCESS;
103#endif 104#endif
104 int parent = 0;
105 int timeout; 105 int timeout;
106 int kill_timeout; 106 int kill_timeout;
107 pid_t pid; 107 pid_t pid;
@@ -119,7 +119,11 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
119 119
120 /* -t SECONDS; -p PARENT_PID */ 120 /* -t SECONDS; -p PARENT_PID */
121 /* '+': stop at first non-option */ 121 /* '+': stop at first non-option */
122#if !ENABLE_PLATFORM_MINGW32
122 getopt32(argv, "+s:k:" USE_FOR_NOMMU("p:+"), &opt_s, &opt_k, &parent); 123 getopt32(argv, "+s:k:" USE_FOR_NOMMU("p:+"), &opt_s, &opt_k, &parent);
124#else
125 getopt32(argv, "+s:k:", &opt_s, &opt_k);
126#endif
123 /*argv += optind; - no, wait for bb_daemonize_or_rexec! */ 127 /*argv += optind; - no, wait for bb_daemonize_or_rexec! */
124 128
125 signo = get_signum(opt_s); 129 signo = get_signum(opt_s);
@@ -212,7 +216,7 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
212 if (kill_timeout > 0) { 216 if (kill_timeout > 0) {
213 if (timeout_wait(kill_timeout, child, &status)) 217 if (timeout_wait(kill_timeout, child, &status))
214 goto finish; 218 goto finish;
215 kill(parent, SIGKILL); 219 kill(pid, SIGKILL);
216 status = 137; 220 status = 137;
217 } 221 }
218 finish: 222 finish: