From c46d8a260d276083092b4a46b049b6aa48a1fdbb Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Fri, 1 Jul 2011 21:11:13 -0400 Subject: always exit from cleanup There's no use case for us calling cleanup without exiting afterwards, so we can simplify all of our cleanup;exit; calls into just cleanup. This means our sighandler is no longer needed (it wasn't really, to begin with), but we split it up to make sure we exit with a posix-ish 128+signum exit value. Signed-off-by: Dave Reisner --- functions | 3 +-- mkinitcpio | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/functions b/functions index 7dfec4c..93a5f7f 100644 --- a/functions +++ b/functions @@ -27,8 +27,7 @@ error() { die() { error "$@" - cleanup - exit 1 + cleanup 1 } get_dirname() { diff --git a/mkinitcpio b/mkinitcpio index 1ac2496..fb705e1 100755 --- a/mkinitcpio +++ b/mkinitcpio @@ -58,8 +58,7 @@ usage: $APPNAME [options] -z COMPRESS Use COMPRESS on resulting image EOF - cleanup - exit 1 + cleanup 1 } cleanup () @@ -71,11 +70,8 @@ cleanup () rm -rf "$TMPDIR" fi fi -} -sighandler() { - cleanup - exit 1 + exit ${1:0} } get_kernver() { @@ -99,7 +95,8 @@ get_kernver() { . "$FUNCTIONS" -trap sighandler TERM INT +trap 'cleanup 130' INT +trap 'cleanup 143' TERM while getopts ':c:k:sb:g:p:m:nvH:LMhS:t:z:' arg; do case "${arg}" in @@ -175,8 +172,7 @@ if [[ $TMPDIR ]]; then if [[ ! -d $TMPDIR ]]; then error "'$TMPDIR' does not exist or is not a directory" unset TMPDIR - cleanup - exit 1 + cleanup 1 fi fi TMPDIR=$(mktemp -d "${TMPDIR:-/tmp}/mkinitcpio.XXXXXX") @@ -231,8 +227,7 @@ if [[ $PRESET ]]; then msg2 "${preset_cmd[*]}" "$0" "${preset_cmd[@]}" done - cleanup - exit 0 + cleanup 0 else die "Preset $PRESET does not exist. Exiting." fi @@ -270,8 +265,7 @@ if (( SHOW_AUTOMODS )); then . "${INSTDIR}/autodetect" build cat "${MODULE_FILE}" - cleanup - exit 0 + cleanup 0 fi @@ -369,8 +363,6 @@ else msg "Dry run complete, use -g IMAGE to generate a real image" fi -cleanup - -exit ${status} +cleanup $status # vim: set ft=sh ts=4 sw=4 et: -- cgit v1.2.3-24-g4f1b