Hi my name is Muhammed,
I wanted to ask why there isn't an option for wait that will take no jobspec or
pid but fail if any of the backgrounded processes fail.
This kind of functionality does not seem intuitive.
When waiting for a specific pid, wait will return the exit code of that
process. Making scripts that rely on a single backgrounded process to succeed
easily managable. However if you need to background multiple tasks and wait for
any of them to fail, you have to do messy shell logic. that stores the pid of
each backgrounded task and then checks them after in a loop for error handling.
This is really messy and there should be an option we can pass to wait which
will handle this functionality for us.
wait -n is also not a good option as it returns the first exit code caught from
backgrounded processes.
Ideally, there should be a wait -e which waits for every child process but
exits on the first non zero exit code received.
I am still a novice scripter so I am interested to learn why there isn't
already an option like this.
Best,Muhammed