mirror of
https://github.com/antos-rde/antos.git
synced 2025-07-14 21:09:53 +02:00
fix: proper way to handle signal + wait for process
This commit is contained in:
Submodule antd/ant-http updated: 58a7738afe...4f91f99ca0
@ -15,7 +15,28 @@ unset ANTOS_PASSWORD
|
|||||||
syslogd -O /tmp/message
|
syslogd -O /tmp/message
|
||||||
|
|
||||||
antd /opt/www/etc/antd-config.ini &
|
antd /opt/www/etc/antd-config.ini &
|
||||||
|
pid=$!
|
||||||
sleep 2
|
sleep 2
|
||||||
runner /opt/www/etc/runner.ini &
|
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
|
Reference in New Issue
Block a user