Only one trap can be added.
authorMilian Wolff <mail@milianw.de>
Thu, 11 Dec 2014 13:37:40 +0000 (14:37 +0100)
committerMilian Wolff <mail@milianw.de>
Thu, 11 Dec 2014 13:37:49 +0000 (14:37 +0100)
This prevents leakage of the /tmp/heaptrack_fifo$$ files.

heaptrack.sh.cmake

index eb54fa9..0a4d469 100755 (executable)
@@ -130,13 +130,17 @@ LIBHEAPTRACK_INJECT=$(readlink -f "$LIBHEAPTRACK_INJECT")
 # setup named pipe to read data from
 pipe=/tmp/heaptrack_fifo$$
 mkfifo $pipe
-trap "rm -f $pipe" EXIT
 
 # interpret the data and compress the output on the fly
 output="$output.gz"
 "$INTERPRETER" < $pipe | gzip -c > "$output" &
 debuggee=$!
-trap "kill $debuggee 2> /dev/null" EXIT
+
+function cleanup {
+    rm -f "$pipe"
+    kill "$debuggee" 2> /dev/null
+}
+trap cleanup EXIT
 
 echo "starting application, this might take some time..."
 echo "output will be written to $output"