From 860b61b04e24a4b8ae4b69273de5d1b88cdf3888 Mon Sep 17 00:00:00 2001 From: DanyLE Date: Wed, 13 Mar 2024 22:51:01 +0100 Subject: [PATCH] fix: proper way to handle signal + wait for process --- antd/ant-http | 2 +- docker/antos/start.sh | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/antd/ant-http b/antd/ant-http index 58a7738..4f91f99 160000 --- a/antd/ant-http +++ b/antd/ant-http @@ -1 +1 @@ -Subproject commit 58a7738afee006a1a816bfab15ae54e879eb723a +Subproject commit 4f91f99ca00d269a35f731a00d6ace31b59c8bb0 diff --git a/docker/antos/start.sh b/docker/antos/start.sh index d6efa71..91cb7f5 100644 --- a/docker/antos/start.sh +++ b/docker/antos/start.sh @@ -15,7 +15,28 @@ unset ANTOS_PASSWORD syslogd -O /tmp/message antd /opt/www/etc/antd-config.ini & +pid=$! sleep 2 runner /opt/www/etc/runner.ini & +#pid_runner=$! -cat \ No newline at end of file +for signal in TERM USR1 HUP INT; do + # shellcheck disable=SC2064 + trap "echo SIGNAL: $signal; kill -s $signal $pid" $signal +done + +# USR2 converted to WINCH +# shellcheck disable=SC2064 +trap "kill -s WINCH $pid" USR2 + +status=999 +while true; do + if [ "${status}" -le 128 ]; then + # Status codes larger than 128 indicates a trapped signal terminated the wait command (128 + SIGNAL). + # In any other case we can stop the loop. + break + fi + wait $pid + status=$? + echo exit status: $status +done \ No newline at end of file