Martin d'Anjou edited a comment on Bug JENKINS-17116

I created this freestyle job, but the traps are never invoked when hitting [x] to "stop" the job.

#!/bin/bash
echo "Starting $0"
echo "Listing traps"
trap -p
echo "Setting trap"
trap 'echo SIGTERM; kill $pid; exit 15;' SIGTERM
trap 'echo SIGINT; kill $pid; exit 2;' SIGINT
echo "Listing traps again"
trap -p
echo "Sleeping"
sleep 10 & pid=$!
echo "Waiting"
wait $pid
echo "Exit status: $?"
echo "Ending"

It looks like Jenkins is using kill -9, but it is not since the rest of the script is executed:

Listing traps
Setting trap
Listing traps again
trap -- 'echo SIGINT; kill $pid; exit 2;' SIGINT
trap -- 'echo SIGTERM; kill $pid; exit 15;' SIGTERM
Sleeping
Waiting
Build was aborted
Aborted by d'Anjou, Martin
Build step 'Groovy Postbuild' marked build as failure
Recording test results
Exit status: 143
Ending

Is it possible that Jenkins disables the traps?

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira

--
You received this message because you are subscribed to the Google Groups "Jenkins Issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-issues+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply via email to