fix trap signals

This commit is contained in:
illiliti 2020-03-01 16:25:52 +03:00
parent 5fe452bcfc
commit eab825a40d

View File

@ -439,14 +439,20 @@ create_initramfs() {
parse_args "$@" parse_args "$@"
parse_conf parse_conf
# remove workdir on exit # remove workdir on signals
trap remove_workdir EXIT # we are doing unset EXIT signal to avoid endless loop
# because afterwards we execute 'exit' command.
# also some shells (dash,mksh,etc) doesn't exit on INT
# signal. as workaround we manually execute exit command.
# tested bash,dash,mksh,busybox sh
# TODO fix zsh, ref https://www.zsh.org/mla/users/2015/msg00436.html
trap "remove_workdir && trap - EXIT && exit" EXIT INT TERM HUP
[ "$debug" = 1 ] && { [ "$debug" = 1 ] && {
# debug shell commands # debug shell commands
set -x set -x
# don't remove anything # don't remove anything
trap - EXIT trap - EXIT INT TERM HUP
} }
create_workdir create_workdir