Bug 15970 - ash: "wait -n" does not return when first pid exits
Summary: ash: "wait -n" does not return when first pid exits
Status: NEW
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-03-05 11:27 UTC by bastian@bastian-friedrich.de
Modified: 2024-03-05 11:27 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bastian@bastian-friedrich.de 2024-03-05 11:27:16 UTC
Hi,

busybox 1.31 introduced the bashism "wait -n". However, that command does not behave the way I expect it to.

Bash's "wait -n" will return when the *first* pid returns; this is not the case for the busybox ash.

In bash, the following script prints "5". In busybox ash, it prints "10".


```
#!/bin/sh

sleep 5 &
pid1=$!

sleep 10 &
pid2=$!

before=$(date +%s)
wait -n $pid1 $pid2
after=$(date +%s)

duration=$(( after - before ))
echo $duration
```