Skip to content
This repository has been archived by the owner on Jun 4, 2018. It is now read-only.

Commit

Permalink
buildiso: finalize error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
udeved committed Jun 13, 2016
1 parent 98b11ef commit 52ce7f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions bin/buildiso.in
Expand Up @@ -169,6 +169,12 @@ done

shift $(($OPTIND - 1))

for sig in TERM HUP QUIT; do
trap "trap_exit $sig \"$(gettext "%s signal caught. Exiting...")\" \"$sig\"" "$sig"
done
trap 'trap_exit INT "$(gettext "Aborted by user! Exiting...")"' INT
trap 'trap_exit USR1 "$(gettext "An unknown error has occurred. Exiting...")"' ERR

timer_start=$(get_timer)

check_root "$0" "${orig_argv[@]}"
Expand Down
10 changes: 9 additions & 1 deletion lib/util-iso.sh
Expand Up @@ -46,7 +46,7 @@ run_safe() {
set -e
set -E
restoretrap=$(trap -p ERR)
trap 'error_function $func' ERR SIGINT SIGTERM
trap 'error_function $func' ERR

if ${verbose};then
run_log "$func"
Expand All @@ -59,6 +59,14 @@ run_safe() {
set +e
}

trap_exit() {
local sig=$1; shift
error "$@"
umount_image
trap -- "$sig"
kill "-$sig" "$$"
}

# $1: image path
make_sqfs() {
if [[ ! -d "$1" ]]; then
Expand Down

1 comment on commit 52ce7f8

@philmmanjaro
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can't work if you never source util-iso.sh

Please sign in to comment.