[pacman-dev] [PATCH v8 02/12] bacman: handle SIGHUP, SIGINT, SIGTERM signals

Gordian Edenhofer gordian.edenhofer at gmail.com
Sun Sep 4 16:13:57 UTC 2016


Trap SIGHUP, SIGINT, SIGTERM and remove working directories accordingly.

Signed-off-by: Gordian Edenhofer <gordian.edenhofer at gmail.com>
---
 contrib/bacman.sh.in | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/contrib/bacman.sh.in b/contrib/bacman.sh.in
index 5e6fce5..e7a7f57 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
 #
-- 
2.9.3


More information about the pacman-dev mailing list