$ cat pids | parallel -j0 cat && echo OK!
cat: 23: No such file or directory
cat: 45: No such file or directory
cat: 67: No such file or directory
cat: 89: No such file or directory
cat: '': No such file or directory
$ cat pids | parallel -j0 echo && echo OK!
parallel does not stop at the first error
$ cat pids | while read pid; do cat \"$pid\" || break; done
cat: '"23"': No such file or directory
$ cat pids | while read pid; do echo \"$pid\" || break; done
bash only: break means break
(Empty last line and return status are implemented differently)
Or do you mean this:
cat pids | while read pid; do cat \"$pid\" || break; done
It does not derive a status, I admit, but that follows a bit from the lacking specifications.
When I run with
echo in the loop it just puts quotes around the lines from file "pids" until EOF. With
||break it stops with an error "no file". Without break it prints many "no file" errors. So it works? Now I just added
&& echo OK, because that command does indeed return 0 or 1, corresponding to the error messages.
The "pids" file contains the pids of course. Piping this file simulates a STREAM of lines with single pids that goes on until it abruptly stops. Indeterminate, just as you say.
Sorry but this Q is absolutely unclear. Different tests on different PIDs indeterminately running.
If you have just any tests then the loop is fine.
If you mean it halfways serious then you have to organize your alogrithm. Break down the logic into smaller steps. Make it easy for you and the CPU.
Your if a then if b then if c then if d then, well, then ALL OK might be borderline OK for one extreme situation. I don't think you have one where this approach is useful.