makepkg: exit via default signal handler in trap_exit
Similar to how we manage receipt of SIGINT in pacman's internal downloader, catch the signal and invoke our own trap handler before unsetting it and calling the default. This requires a slight modification to the arguments passed to trap_exit so we can pass the raised signal to trap_exit (note that we substitue USR1 for ERR since the latter is unique to bash). Fixes FS#28491. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
1fe6cabc4d
commit
1a8c3e52d7
1 changed files with 9 additions and 4 deletions
|
@ -118,12 +118,17 @@ error() {
|
||||||
# the fakeroot call, the error message will be printed by the main call.
|
# the fakeroot call, the error message will be printed by the main call.
|
||||||
##
|
##
|
||||||
trap_exit() {
|
trap_exit() {
|
||||||
|
local signal=$1; shift
|
||||||
|
|
||||||
if (( ! INFAKEROOT )); then
|
if (( ! INFAKEROOT )); then
|
||||||
echo
|
echo
|
||||||
error "$@"
|
error "$@"
|
||||||
fi
|
fi
|
||||||
[[ -n $srclinks ]] && rm -rf "$srclinks"
|
[[ -n $srclinks ]] && rm -rf "$srclinks"
|
||||||
exit 1
|
|
||||||
|
# unset the trap for this signal, and then call the default handler
|
||||||
|
trap -- "$signal"
|
||||||
|
kill "-$signal" "$$"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1964,10 +1969,10 @@ done
|
||||||
# setup signal traps
|
# setup signal traps
|
||||||
trap 'clean_up' 0
|
trap 'clean_up' 0
|
||||||
for signal in TERM HUP QUIT; do
|
for signal in TERM HUP QUIT; do
|
||||||
trap "trap_exit \"$(gettext "%s signal caught. Exiting...")\" \"$signal\"" "$signal"
|
trap "trap_exit $signal \"$(gettext "%s signal caught. Exiting...")\" \"$signal\"" "$signal"
|
||||||
done
|
done
|
||||||
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
|
trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
|
||||||
trap 'trap_exit "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR
|
||||||
set -E
|
set -E
|
||||||
|
|
||||||
# preserve environment variables and canonicalize path
|
# preserve environment variables and canonicalize path
|
||||||
|
|
Loading…
Add table
Reference in a new issue