fix: proper way to handle signal + wait for process
gitea-sync/antos/pipeline/head This commit looks good Details
gitea-sync/antos/pipeline/tag This commit looks good Details

This commit is contained in:
DanyLE 2024-03-13 22:51:01 +01:00
parent b2d766849c
commit 860b61b04e
2 changed files with 23 additions and 2 deletions

@ -1 +1 @@
Subproject commit 58a7738afee006a1a816bfab15ae54e879eb723a
Subproject commit 4f91f99ca00d269a35f731a00d6ace31b59c8bb0

View File

@ -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
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