aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2016-08-04 23:37:09 +1200
committerTom Ryder <tom@sanctum.geek.nz>2016-08-04 23:37:09 +1200
commit1b0a9d30ea5e95929589b19acb36786317c5637a (patch)
treebd90f9b853b368d70cc2bfa0c8b8793d334f3783
parentTrying new 'breakindent' Vim feature (diff)
downloaddotfiles-1b0a9d30ea5e95929589b19acb36786317c5637a.tar.gz
dotfiles-1b0a9d30ea5e95929589b19acb36786317c5637a.zip
Add missing code to tmpfile cleanup hooks
-rwxr-xr-xbin/rndl8
-rwxr-xr-xbin/tlcs8
-rw-r--r--man/man1/mktd.110
3 files changed, 19 insertions, 7 deletions
diff --git a/bin/rndl b/bin/rndl
index 3e92044c..14721539 100755
--- a/bin/rndl
+++ b/bin/rndl
@@ -3,10 +3,14 @@
if [ "$#" -eq 0 ] ; then
td=
cleanup() {
- rm -fr -- "$td"
+ [ "$td" ] && rm -fr -- "$td"
+ if [ "$1" != EXIT ] ; then
+ trap - "$1"
+ kill "-$1" "$$"
+ fi
}
for sig in EXIT HUP INT TERM ; do
- trap cleanup "$sig"
+ trap "cleanup $sig" "$sig"
done
td=$(mktd rndl) || exit
set -- "$td"/stdin
diff --git a/bin/tlcs b/bin/tlcs
index 8ba6cefc..996fb5ce 100755
--- a/bin/tlcs
+++ b/bin/tlcs
@@ -70,10 +70,14 @@ fi
# Temporary directory for the FIFOs
td=
cleanup() {
- rm -fr -- "$td"
+ [ "$td" ] && rm -fr -- "$td"
+ if [ "$1" != EXIT ] ; then
+ trap - "$1"
+ kill "-$1" "$$"
+ fi
}
for sig in EXIT HUP INT TERM ; do
- trap cleanup "$sig"
+ trap "cleanup $sig" "$sig"
done
td=$(mktd "$self") || exit
diff --git a/man/man1/mktd.1 b/man/man1/mktd.1
index bb88a12e..680cbd61 100644
--- a/man/man1/mktd.1
+++ b/man/man1/mktd.1
@@ -20,12 +20,16 @@ You could use it in a script like this:
.P
td=
cleanup() {
- rm -fr -- "$td"
+ [ "$td" ] && rm -fr -- "$td"
+ if [ "$1" != EXIT ] ; then
+ trap - "$1"
+ kill "-$1" "$$"
+ fi
}
for sig in EXIT HUP INT TERM ; do
- trap cleanup "$sig"
+ trap "cleanup $sig" "$sig"
done
- td=$(mktd) || exit
+ td=$(mktd myprogram) || exit
.SH SEE ALSO
rndi(1)
.br