Parallel xargs fails if any of its children do
We like to write about
xargs. In addition to all that, turns out
xargs is a great tool for easily parallelizing tests, linters or anything where some may pass, and some may fail. If any of the processes that
xargs spawns fail, the
xargs call will also fail.
All child processes exit zero:
% echo "0\n0\n0" | xargs -Icode -P4 sh -c 'exit code'; echo exit code: $? exit code: 0
And so does
xargs! If any exit non-zero:
echo "0\n1\n127" | xargs -Icode -P4 sh -c 'exit code'; echo exit code: $? exit code: 1
xargs follows suit.