From bd020b6a77a59ebe14ba1a44d29239b760ab51df Mon Sep 17 00:00:00 2001 From: merakor Date: Mon, 10 May 2021 07:00:39 +0000 Subject: fix handling of interrupt signals on the download operation FossilOrigin-Name: dde4df8fc98bbe3b8ad590d50ab4309a746ca0231d1398cbdbead7c1fa91e89f --- src/cpt-lib.in | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/cpt-lib.in b/src/cpt-lib.in index 5416efe..930c426 100644 --- a/src/cpt-lib.in +++ b/src/cpt-lib.in @@ -43,8 +43,11 @@ trap_set() { trap pkg_clean EXIT trap 'pkg_clean; exit 1' INT ;; - block) trap '' INT ;; - unset) trap - EXIT INT ;; + handle-int) + trap pkg_clean INT + ;; + block) trap '' INT ;; + unset) trap - EXIT INT ;; esac } @@ -703,11 +706,18 @@ pkg_sources() { elif [ -z "${src##*://*}" ]; then log "$1" "Downloading $src" + # We don't want our trap to exit immediately here if we receive an + # interrupt, we handle this ourselves. + trap_set handle-int + curl "$src" -fLo "${src##*/}" || { rm -f "${src##*/}" die "$1" "Failed to download $src" } + # Restore original trap value. + trap_set cleanup + # Local source. elif [ -f "$repo_dir/$src" ]; then log "$1" "Found local file '$src'" -- cgit v1.2.3