commit 4510395a410d74e6f2b63776319ac35ccc414cd9
parent 1b5891b03d4578526823ea1c8f93c87cdfa6e85b
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri,  7 Sep 2018 19:05:40 +0200
sfeed_update: don't always exit 1, exit 130 on SIGINT, exit 0 otherwise
Reported by "Dekedro", thanks!
Diffstat:
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git 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