Running an EXIT trap on abnormal termination of the shell is a bashism;
dash, for instance, does not run them on SIGINT.
Fix by explicitly adding a trap for SIGINT.
Signed-off-by: Wouter Verhelst <w@uter.be>
set -e
-trap cleanup EXIT
-
cleanup() {
if [ -f ${pidfile} ]
then
if [ ! -z "$PID" ]
then
kill $PID || true
+ else
+ echo "E: Could not clean up!"
fi
fi
if [ -z "$cleanup" ]
fi
}
+abort() {
+ cleanup
+ trap - INT
+ kill -INT $$
+}
+
+trap -- cleanup EXIT
+trap -- abort INT
+
# Create a one-meg device
dd if=/dev/zero of=$tmpnam bs=1024 count=4096 >/dev/null 2>&1