From 4510395a410d74e6f2b63776319ac35ccc414cd9 Mon Sep 17 00:00:00 2001 From: Hiltjo Posthuma Date: Fri, 7 Sep 2018 19:05:40 +0200 Subject: sfeed_update: don't always exit 1, exit 130 on SIGINT, exit 0 otherwise Reported by "Dekedro", thanks! --- sfeed_update | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/sfeed_update b/sfeed_update index c81ec6b..7578a1d 100755 --- a/sfeed_update +++ b/sfeed_update @@ -97,8 +97,8 @@ feed() { fi) & } -terminated() { - isrunning="0" +interrupted() { + isinterrupted="1" } cleanup() { @@ -115,10 +115,10 @@ feeds() { loadconfig "$1" # fetch feeds and store in temporary file. sfeedtmpdir="$(mktemp -d '/tmp/sfeed_XXXXXX')" -# kill whole current process group on ^C. -isrunning="1" +# kill whole current process group on ^C (SIGINT). +isinterrupted="0" # SIGTERM: signal to terminate parent. -trap -- "terminated" "15" +trap -- "interrupted" "15" # SIGINT: kill all running childs >:D trap -- "kill -TERM -$$" "2" # make sure path exists. @@ -129,5 +129,6 @@ feeds wait # cleanup temporary files etc. cleanup -# if terminated. -[ "${isrunning}" = "0" ] && exit 1 +# on SIGINT exit with 128 + signal (SIGINT = 2). +[ "${isinterrupted}" = "1" ] && exit 130 +exit 0 -- cgit v1.2.3