There is more to it than cleaning up the orphaned processes, which by the way should be done by Jenkins and not as an external process. The way this should work is that Jenkins should send the signal (SIGTERM or SIGTERM) and wait for the sub-processes to do their own cleanup. This gives the sub-processes a chance to propagate the signal to sub-sub-processes of their own (which by the way when you use a grid engine, might be running yet on other remote machines that are not Jenkins slaves).

I modified the first shell script to write to a file during the traps: Jenkins cuts the ties too early and no files show up anywhere.

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

So the SIGINT -> wait N seconds for the build process to return -> SIGKILL (with a user configurable N) would be an acceptable solution. The value of N should be configurable for each job.

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/d/optout.

Reply via email to