Broaden trap() functionality

Resolves #236 and #247

* Broaden trapped signals to SIGHUB, SIGINT, SIGQUIT, SIGABRT
* Turn echo back on upon exit.
* Provide a newline at exit just to make the terminal look pretty.

Signed-off-by: Eric F Crist <ecrist@secure-computing.net>
This commit is contained in:
Eric F Crist 2018-10-02 10:02:40 -05:00
parent 8356b3231d
commit 446a58f9f3
No known key found for this signature in database
GPG Key ID: 72964219390D0D0E

View File

@ -287,6 +287,14 @@ clean_temp() {
done
} # => clean_temp()
prog_exit() {
ESTAT=0
[ ! -z "$1" ] && ESTAT=$1
(set -o echo 2>/dev/null) || stty echo
echo "" # just to get a clean line
exit $ESTAT
} # => prog_exit()
# Make LibreSSL safe config file from OpenSSL config file
make_ssl_config() {
sed -e "s,ENV::,,g" \
@ -1318,8 +1326,8 @@ done
# Intelligent env-var detection and auto-loading:
vars_setup
# Register clean_temp on EXIT
trap "clean_temp" EXIT
# Register clean_temp and prog_exit on SIGHUP, SIGINT, SIGQUIT, and SIGABRT
trap "clean_temp; prog_exit" 1 2 3 6
# determine how we were called, then hand off to the function responsible
cmd="$1"