# `wait` knows the status of a background job after it was reaped, also when
# that job was not the most recent one and so not the one `$!` names.
false & a=$!
true & b=$!
sleep 0.3
:
wait $a; echo "wait a: $?"
wait $a; echo "again: $?"
false & c=$!
true & d=$!
sleep 0.3
wait $c $d; echo "both: $?"
wait; echo "all: $?"