Bug 15970

Summary: ash: "wait -n" does not return when first pid exits
Product: Busybox Reporter: bastian <bastian>
Component: OtherAssignee: unassigned
Status: NEW ---    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: All   
Host: Target:
Build:

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
```