Bash trapping not working to get the timeout and interrupted jobs


#1

Hello Colleagues,

Actually, We trying to capture the timeout or interrupted jobs status. For that, We are using trapping the SIGTERM signal. It works fine on OpenStack/GCP and Azure but not working on the AWS concourse setup.

In AWS it exciting while executing the curl command. Also, I have tried from container(using gaol cli) there trapping the signal worked. Not sure why via concourse ui it is not working. Any help here?

#!/usr/bin/env bash
echo “pid is $$”
function finish {
measurement=xxxxx
echo “$measurement” > curl.input
curl -v --connect-timeout 15 -m 30 --retry 6 --retry-delay 0 --retry-max-time 60 -u u:p -L -sw ‘%{http_code}\n’ -o /tmp/curl.out -XPOST ‘https://url/write?db=abc’ --data-binary @/tmp/curl.input
echo “Booh!”
exit 0
}
trap finish SIGINT SIGTERM EXIT
echo “abcccccccccccccccccccccc”
a=1
while [[ $in != “^D” ]]; do
echo $a
sleep 1
((a+=1))
done

BRs, Gowrisankar