From 5b3631dc8052c2ba223b7c54230cc980105aad3d Mon Sep 17 00:00:00 2001 From: Jonathan Harden Date: Wed, 15 May 2024 16:32:45 +0100 Subject: [PATCH] Use a trap to kill /opt/go/out when term is sent by concourse Signed-off-by: Jonathan Harden --- assets/out | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/assets/out b/assets/out index 937de29..893b97e 100755 --- a/assets/out +++ b/assets/out @@ -17,4 +17,13 @@ git_config_payload=$(jq -r '.source.git_config // []' < $payload) configure_git_global "${git_config_payload}" -/opt/go/out $1 >&3 < $payload +_terminate() { + kill -TERM "$child" 2>/dev/null +} + +trap _terminate TERM + +/opt/go/out $1 >&3 < $payload & + +child=$! +wait "$child"