#!/bin/sh

pids=()
for i in {1..10}; do
	sleep 10 &
	pids+=($!)
done

set | grep pids

results=()
for i in ${pids[@]}; do
	wait -n $i
	results+=($?)
done

set | grep results
