aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2016-11-07 23:07:21 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2016-11-07 23:07:21 +0100
commit26ad94bedcc6a4aa3feb07ea032709bcd517ee46 (patch)
treeb37f58cf17146d1b6945fa3991585e81223ba286 /shell
parent62b717b75ebff3ab00aae2fee0087a8106208a39 (diff)
downloadbusybox-26ad94bedcc6a4aa3feb07ea032709bcd517ee46.tar.gz
hush: "wait $!; echo $?" should return 127 if $! already exited
It would be nice to provide bash-like "remember las exitcode" thingy, but it's a bit complex. For now, match ash and dash. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/shell/hush.c b/shell/hush.c
index b842d6eec..7683a3749 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -9636,12 +9636,13 @@ static int FAST_FUNC builtin_wait(char **argv)
/* "wait $!" but last bg task has already exited. Try:
* (sleep 1; exit 3) & sleep 2; echo $?; wait $!; echo $?
* In bash it prints exitcode 0, then 3.
+ * In dash, it is 127.
*/
- ret = 0; /* FIXME */
- continue;
+ /* ret = G.last_bg_pid_exitstatus - FIXME */
+ } else {
+ /* Example: "wait 1". mimic bash message */
+ bb_error_msg("wait: pid %d is not a child of this shell", (int)pid);
}
- /* Example: "wait 1". mimic bash message */
- bb_error_msg("wait: pid %d is not a child of this shell", (int)pid);
} else {
/* ??? */
bb_perror_msg("wait %s", *argv);