I have a simple bash script:
echo "Starting"
function sigint {
echo "sigint"
}
function sigterm {
echo "sigterm"
}
trap sigterm SIGTERM
trap sigint SIGINT
while true
do
sleep 2
echo "-"
done
I launch this script with upstart using this config file:
description "start trapper"
kill timeout 1
script
./home/ubuntu/trapper.sh >> /home/ubuntu/log.txt
end script
post-stop script
echo "finished" >> /home/ubuntu/log.txt
end script
When I start it, with upstart, I can monitor the output of it in /home/ubuntu/log.txt
. The problem is, when I stop my job, I see sigterm is sent to my program (it prints it), I then directly see "finished" (which is written in the post-stop script), but I still see "-" printed every 2 seconds ...
What happens is that upstart never send SIGKILL to my script, even if it says that stop succeeded (since it enters in the post-stop script).
Any help would be great !