aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2024-10-28 13:50:59 +0000
committerRon Yorston <rmy@pobox.com>2024-10-28 13:50:59 +0000
commit1bdb630cc7b17ca69598bf47ef5ae1b6565c7207 (patch)
tree66d81c901b565934ea8a2d52c3ba153383a0aa29
parentb4684bee87cb4acf392f27003c702d6650eda469 (diff)
downloadbusybox-w32-1bdb630cc7b17ca69598bf47ef5ae1b6565c7207.tar.gz
busybox-w32-1bdb630cc7b17ca69598bf47ef5ae1b6565c7207.tar.bz2
busybox-w32-1bdb630cc7b17ca69598bf47ef5ae1b6565c7207.zip
ash: fix waiting for status of background job
The following has never worked properly in busybox-w32: $ my_func() { return 5; } $ my_func & sleep 1; wait $!; echo $? The expected result is that 'echo' should display '5'. Actual results used to be '0' and more recently have been '127'. The culprit was commit fa6f44ea72 (win32: ash: reimplement waitpid(-1)). When the status of a job changed its pid was set to -1, which flagged processes of interest to the implementation of waitpid(). This is no longer necessary as waitpid() now uses the process handle instead. There's therefore no need to overwrite the pid. (GitHub issue #470)
-rw-r--r--shell/ash.c1
1 files changed, 0 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index f21ef85d4..fd2a66270 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -5070,7 +5070,6 @@ waitone(int block, struct job *job)
5070 ps->ps_status = status; 5070 ps->ps_status = status;
5071 thisjob = jp; 5071 thisjob = jp;
5072#if ENABLE_PLATFORM_MINGW32 5072#if ENABLE_PLATFORM_MINGW32
5073 ps->ps_pid = -1;
5074 CloseHandle(ps->ps_proc); 5073 CloseHandle(ps->ps_proc);
5075 ps->ps_proc = NULL; 5074 ps->ps_proc = NULL;
5076#endif 5075#endif