On Tue, Mar 12, 2024 at 10:33:36AM +0100, Mischa Baars wrote: > bash -c 'set +m; seconds=1; for (( i=0;i<32;i++ )); do exit ${i} & done; > sleep ${seconds}; for (( i=0;i<32;i++ )); do wait -p pid; e=${?}; echo > "$(printf %3u ${i}) pid ${pid} exit ${e}"; done;'
"wait -p pid" is not correct here. In that command, pid is an output variable, and you have not specified any process IDs to wait for -- so wait is going to wait for *all* of the children to finish, and you'll get zero as the exit status: $ help wait [...] Waits for each process identified by an ID, which may be a process ID or a job specification, and reports its termination status. If ID is not given, waits for all currently active child processes, and the return status is zero. If ID is a job specification, waits for all processes in that job's pipeline.