In sh, is it defined that it works to wait for a background job that has already terminated the time wait is invoked? SUS talks about PIDs "known to the invoking shell" and I'm not sure if something else than wait-ing can make a PID unknown.
Is there a more elegant portable (i.e. not using wait -n) way to background several commands and collect their individual rcs than remembering their PIDs and which PID corresponds to which command, then looping through the PID list, wait for each one in turn and associate the rc with the command remembered? Is that defined to work? In case someone is wondering: I want to scan (dd -of /dev/null) several discs in parallel and of course gather which one, if any, failed.
