[PATCH] pkg_sources(): restore old trap for handling curl

[PATCH] pkg_sources(): restore old trap for handling curl

From: Cem Keylan
To: dev
Most of the time you want the package manager to cleanup and exit
directly after receiving interrupt signal. However, there are some
places (such as the download operation here) where we want to handle
interrupts.
---
 kiss | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/kiss b/kiss
index d4b829a..e343024 100755
--- a/kiss
+++ b/kiss
@@ -219,11 +219,18 @@ pkg_sources() {
             log "$1" "Downloading $src"
             mkdir -p "$PWD/$dest"
 
+            # We don't want interrupt to exit immediately here, so we change the
+            # behaviour here.
+            trap pkg_clean INT
+
             curl "$src" -fLo "./${dest:-.}/${src##*/}" || {
                 rm -f "./${dest:-.}/${src##*/}"
                 die "$1" "Failed to download $src"
             }
 
+            # Restore the trap to the original value.
+            trap 'pkg_clean; exit 1' INT
+
         # Local source (relative).
         elif [ -e "$repo_dir/$src" ]; then
             log "$1" "Found local relative source '$src'"
-- 
2.31.1


Re: [PATCH] pkg_sources(): restore old trap for handling curl

From: Dilyn Corner
To: dev
On Sun May 9, 2021 at 6:29 AM EDT, Cem Keylan wrote:
> Most of the time you want the package manager to cleanup and exit
> directly after receiving interrupt signal. However, there are some
> places (such as the download operation here) where we want to handle
> interrupts.

Is there anywhere else that trap handling is \broken\? I'm not seeing anything
else but I can quite easily miss some things.