Commit 6da33e3a authored by 神楽坂玲奈's avatar 神楽坂玲奈

signal

parent c5054498
Pipeline #15944 failed with stages
in 49 seconds
...@@ -18,4 +18,27 @@ echo $interface up ...@@ -18,4 +18,27 @@ echo $interface up
PATH=$PATH:/ iptables -V PATH=$PATH:/ iptables -V
#trap 等信号来了down #trap 等信号来了down
sleep infinity pid=0
run_stop() {
signalCode=$1
if [ -n "$DOWN_SCRIPT" ]; then
eval "$DOWN_SCRIPT"
fi
if [ $pid -ne 0 ]; then
kill "-$signalCode" "$pid"
wait "$pid"
fi
exit $((128 + signalCode));
}
trap 'kill ${!}; run_stop 2' SIGTERM
trap 'kill ${!}; run_stop 15' SIGINT
sleep infinity &
pid="$!"
# wait forever
wait "$pid"
pid=0
run_stop 1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment