diff options
author | Ron Yorston <rmy@pobox.com> | 2024-07-28 12:48:40 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2024-07-28 12:48:40 +0100 |
commit | bb8f6b688a6a8c7ac66b5c656d2544f9167a1abe (patch) | |
tree | 42b5f06c92dad20f5d9f85e349b6f1084490ed0b /shell/ash.c | |
parent | fe927d870601af570b22889ecc267b008af35404 (diff) | |
download | busybox-w32-bb8f6b688a6a8c7ac66b5c656d2544f9167a1abe.tar.gz busybox-w32-bb8f6b688a6a8c7ac66b5c656d2544f9167a1abe.tar.bz2 busybox-w32-bb8f6b688a6a8c7ac66b5c656d2544f9167a1abe.zip |
ash: fix slow running when background job is present
It was noted that a simple 'while' loop would take considerably
longer to run in a shell which had spawned a background job
compared to one that hadn't.
The problem originates with commit 4d8a277d59 (Implement nonblocking
wait) which introduced a nonblocking wait in ash.
This was found to cause the shell to use 100% of CPU when running
'sleep 60'. This was 'fixed' by commit 88b8cb61e (ash: Add a very
small timeout to nonblocking wait).
Subsequently commit 96c9c0044 (ash: allow waitpid_child to block)
fixed a problem with the logic of the original commit, but it left
the small timeout in place. It is this timeout which slows down
the shell when a background job is present.
The solution is to restore the 0 timeout for the nonblocking wait.
Saves 0-16 bytes.
(GitHub issue #434)
Diffstat (limited to '')
-rw-r--r-- | shell/ash.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c index 4b063217a..ba29e3ea0 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -4960,7 +4960,7 @@ waitpid_child(int *status, int wait_flags) | |||
4960 | goto done; | 4960 | goto done; |
4961 | 4961 | ||
4962 | idx = WaitForMultipleObjects(pid_nr, proclist, FALSE, | 4962 | idx = WaitForMultipleObjects(pid_nr, proclist, FALSE, |
4963 | wait_flags&WNOHANG ? 1 : INFINITE); | 4963 | wait_flags & WNOHANG ? 0 : INFINITE); |
4964 | if (idx < pid_nr) { | 4964 | if (idx < pid_nr) { |
4965 | GetExitCodeProcess(proclist[idx], &win_status); | 4965 | GetExitCodeProcess(proclist[idx], &win_status); |
4966 | *status = exit_code_to_wait_status(win_status); | 4966 | *status = exit_code_to_wait_status(win_status); |