diff options
author | Ron Yorston <rmy@pobox.com> | 2019-03-31 09:27:09 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-04-02 13:43:40 +0200 |
commit | e48559eae3ba10e4b4f4c2ce726c31fd038a37ba (patch) | |
tree | 6a4d404ff48ce5b0230d7ac54878601ce72afa7c | |
parent | 8939359180ad0d6bfaaca694c4f14cd15cde4788 (diff) | |
download | busybox-w32-e48559eae3ba10e4b4f4c2ce726c31fd038a37ba.tar.gz busybox-w32-e48559eae3ba10e4b4f4c2ce726c31fd038a37ba.tar.bz2 busybox-w32-e48559eae3ba10e4b4f4c2ce726c31fd038a37ba.zip |
ash: distinguish 'wait -n' from other bashisms
Add a specific define to indicate which bash compatibility code
implements 'wait -n'.
Signed-off-by: Ron Yorston <rmy@pobox.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/shell/ash.c b/shell/ash.c index b1499b037..34d5d6d68 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -224,6 +224,7 @@ | |||
224 | #define BASH_XTRACEFD ENABLE_ASH_BASH_COMPAT | 224 | #define BASH_XTRACEFD ENABLE_ASH_BASH_COMPAT |
225 | #define BASH_READ_D ENABLE_ASH_BASH_COMPAT | 225 | #define BASH_READ_D ENABLE_ASH_BASH_COMPAT |
226 | #define IF_BASH_READ_D IF_ASH_BASH_COMPAT | 226 | #define IF_BASH_READ_D IF_ASH_BASH_COMPAT |
227 | #define BASH_WAIT_N ENABLE_ASH_BASH_COMPAT | ||
227 | 228 | ||
228 | #if defined(__ANDROID_API__) && __ANDROID_API__ <= 24 | 229 | #if defined(__ANDROID_API__) && __ANDROID_API__ <= 24 |
229 | /* Bionic at least up to version 24 has no glob() */ | 230 | /* Bionic at least up to version 24 has no glob() */ |
@@ -4235,7 +4236,7 @@ wait_block_or_sig(int *status) | |||
4235 | #define DOWAIT_NONBLOCK 0 | 4236 | #define DOWAIT_NONBLOCK 0 |
4236 | #define DOWAIT_BLOCK 1 | 4237 | #define DOWAIT_BLOCK 1 |
4237 | #define DOWAIT_BLOCK_OR_SIG 2 | 4238 | #define DOWAIT_BLOCK_OR_SIG 2 |
4238 | #if ENABLE_ASH_BASH_COMPAT | 4239 | #if BASH_WAIT_N |
4239 | # define DOWAIT_JOBSTATUS 0x10 /* OR this to get job's exitstatus instead of pid */ | 4240 | # define DOWAIT_JOBSTATUS 0x10 /* OR this to get job's exitstatus instead of pid */ |
4240 | #endif | 4241 | #endif |
4241 | 4242 | ||
@@ -4246,7 +4247,7 @@ dowait(int block, struct job *job) | |||
4246 | int status; | 4247 | int status; |
4247 | struct job *jp; | 4248 | struct job *jp; |
4248 | struct job *thisjob; | 4249 | struct job *thisjob; |
4249 | #if ENABLE_ASH_BASH_COMPAT | 4250 | #if BASH_WAIT_N |
4250 | bool want_jobexitstatus = (block & DOWAIT_JOBSTATUS); | 4251 | bool want_jobexitstatus = (block & DOWAIT_JOBSTATUS); |
4251 | block = (block & ~DOWAIT_JOBSTATUS); | 4252 | block = (block & ~DOWAIT_JOBSTATUS); |
4252 | #endif | 4253 | #endif |
@@ -4348,7 +4349,7 @@ dowait(int block, struct job *job) | |||
4348 | out: | 4349 | out: |
4349 | INT_ON; | 4350 | INT_ON; |
4350 | 4351 | ||
4351 | #if ENABLE_ASH_BASH_COMPAT | 4352 | #if BASH_WAIT_N |
4352 | if (want_jobexitstatus) { | 4353 | if (want_jobexitstatus) { |
4353 | pid = -1; | 4354 | pid = -1; |
4354 | if (thisjob && thisjob->state == JOBDONE) | 4355 | if (thisjob && thisjob->state == JOBDONE) |
@@ -4537,7 +4538,7 @@ waitcmd(int argc UNUSED_PARAM, char **argv) | |||
4537 | struct job *job; | 4538 | struct job *job; |
4538 | int retval; | 4539 | int retval; |
4539 | struct job *jp; | 4540 | struct job *jp; |
4540 | #if ENABLE_ASH_BASH_COMPAT | 4541 | #if BASH_WAIT_N |
4541 | int status; | 4542 | int status; |
4542 | char one = nextopt("n"); | 4543 | char one = nextopt("n"); |
4543 | #else | 4544 | #else |
@@ -4550,7 +4551,7 @@ waitcmd(int argc UNUSED_PARAM, char **argv) | |||
4550 | /* wait for all jobs / one job if -n */ | 4551 | /* wait for all jobs / one job if -n */ |
4551 | for (;;) { | 4552 | for (;;) { |
4552 | jp = curjob; | 4553 | jp = curjob; |
4553 | #if ENABLE_ASH_BASH_COMPAT | 4554 | #if BASH_WAIT_N |
4554 | if (one && !jp) | 4555 | if (one && !jp) |
4555 | /* exitcode of "wait -n" with nothing to wait for is 127, not 0 */ | 4556 | /* exitcode of "wait -n" with nothing to wait for is 127, not 0 */ |
4556 | retval = 127; | 4557 | retval = 127; |
@@ -4570,7 +4571,7 @@ waitcmd(int argc UNUSED_PARAM, char **argv) | |||
4570 | * with an exit status greater than 128, immediately after which | 4571 | * with an exit status greater than 128, immediately after which |
4571 | * the trap is executed." | 4572 | * the trap is executed." |
4572 | */ | 4573 | */ |
4573 | #if ENABLE_ASH_BASH_COMPAT | 4574 | #if BASH_WAIT_N |
4574 | status = dowait(DOWAIT_BLOCK_OR_SIG | DOWAIT_JOBSTATUS, NULL); | 4575 | status = dowait(DOWAIT_BLOCK_OR_SIG | DOWAIT_JOBSTATUS, NULL); |
4575 | #else | 4576 | #else |
4576 | dowait(DOWAIT_BLOCK_OR_SIG, NULL); | 4577 | dowait(DOWAIT_BLOCK_OR_SIG, NULL); |
@@ -4581,7 +4582,7 @@ waitcmd(int argc UNUSED_PARAM, char **argv) | |||
4581 | */ | 4582 | */ |
4582 | if (pending_sig) | 4583 | if (pending_sig) |
4583 | goto sigout; | 4584 | goto sigout; |
4584 | #if ENABLE_ASH_BASH_COMPAT | 4585 | #if BASH_WAIT_N |
4585 | if (one) { | 4586 | if (one) { |
4586 | /* wait -n waits for one _job_, not one _process_. | 4587 | /* wait -n waits for one _job_, not one _process_. |
4587 | * date; sleep 3 & sleep 2 | sleep 1 & wait -n; date | 4588 | * date; sleep 3 & sleep 2 | sleep 1 & wait -n; date |