The two functions waitForRegisteredPids and the _BashSucksVersion wait for all pids en bloc. It is not possible to say exactly, which PID produced the error code.
Use a for-loop and report the PID and maybe index. After switching the PID registry to be a associative array, report the array keys.
Report all failed PIDs with error codes. Accumulate the errors and fail if one or more failed.
The two functions waitForRegisteredPids and the _BashSucksVersion wait for all pids en bloc. It is not possible to say exactly, which PID produced the error code.