I have the following bash script:

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?


Quote from https://stackoverflow.com/a/7294947/402322

Also, if the program dies because of a signal, bash lets you know by encoding the exit status as:

128 + signal-number

Hence SIGHUP yields 129, SIGILL yields 132, SIGTERM yields 143, etc.

The above means, that your process has got SIGTERM.

You have three kills in your code. If you can exclude kill %1 one of the other two kill 0 sends the TERM signal.

  • This has nothing to do with the question. – Gilles 'SO- stop being evil' Feb 16 '17 at 23:27
  • Please explain how this relates to the question. – Scott Feb 17 '17 at 0:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.