I have the following bash script:
#!/bin/bash
set -m
(
(bin/pnvd &> /dev/null; kill 0) &
sleep 2
perl integration-test/fuzz-test.pl || kill 0
kill %1
)
The first three commands in the subshell succeed and return exit status 0. bin/pnvd
never exits until it is killed externally.
However after executing the forth command in the subshell, the script exits with this output:
tools/integration-test: line 8: 4712 Terminated ( ( bin/pnvd &> /dev/null; kill 0 ) & sleep 2; perl integration-test/fuzz-test.pl || kill 0; kill %1 )
and status code 143.
It looks as if kill %1
kills the whole process group, not just the first job, however if I remove set -m
then it exits with status 0.
I am not so much interested in how to fix this but more in: why does the subshell exit with status 143 when it kills the first job?