From 52ec8dfffee862511d07bbd98293c605ac075656 Mon Sep 17 00:00:00 2001 From: Gordian Edenhofer Date: Sun, 4 Sep 2016 18:13:57 +0200 Subject: bacman: handle SIGHUP, SIGINT, SIGTERM signals Trap SIGHUP, SIGINT, SIGTERM and remove working directories accordingly. Signed-off-by: Gordian Edenhofer Signed-off-by: Allan McRae --- contrib/bacman.sh.in | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'contrib') diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in index 5e6fce56..e7a7f576 100644 --- a/contrib/bacman.sh.in +++ b/contrib/bacman.sh.in @@ -33,6 +33,16 @@ ARGS=("$@") m4_include(../scripts/library/output_format.sh) +# Lazy recursive clean up of temporary dirs +work_dir_root="${TMPDIR:-/tmp}/bacman" +clean_up() { + rm -rf "$work_dir_root".* + echo + exit +} +# Trap termination signals +trap clean_up SIGHUP SIGINT SIGTERM + # # User Friendliness # -- cgit v1.2.3-70-g09d2