sfeed

Simple RSS and Atom feed parser
git clone https://git.sinitax.com/codemadness/sfeed
Log | Files | Refs | README | LICENSE | Upstream | sfeed.txt

commit bb6dd44d8638ccba315973f2c6c66262ef72f1d2
parent 774dc3ed45bc2a1efcddeea2eb885e140949f9eb
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Fri,  5 Oct 2018 20:43:24 +0200

sfeed_update: improve SIGINT handling

When SIGINT occurs on waiting for jobs it returns 130 (128 + SIGINT). Make sure
to check for interrupted and return immediately.

Tested with ksh, dash, bash, zsh.

Sidenote: ideally we want to cleanup() on SIGTERM too, but this is too
inconsistent over various shells.

Diffstat:
Msfeed_update | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sfeed_update b/sfeed_update @@ -78,6 +78,7 @@ feed() { # wait until ${maxjobs} are finished: throughput using this logic is # non-optimal, but it is simple and portable. [ $((curjobs % maxjobs)) -eq 0 ] && wait + [ ${isinterrupted} -eq 1 ] && return curjobs=$((curjobs + 1)) (name="$1" @@ -123,7 +124,7 @@ cleanup() { } interrupted() { - isinterrupted="1" + isinterrupted=1 } feeds() { @@ -134,7 +135,7 @@ feeds() { # job counter. curjobs=0 # kill whole current process group on ^C (SIGINT). -isinterrupted="0" +isinterrupted=0 # SIGTERM: signal to terminate parent. trap -- "interrupted" "TERM" # SIGINT: kill all running childs >:D @@ -152,5 +153,5 @@ wait # cleanup temporary files etc. cleanup # on SIGINT exit with 128 + signal (SIGINT = 2). -[ "${isinterrupted}" = "1" ] && exit 130 +[ ${isinterrupted} -eq 1 ] && exit 130 exit 0