From ae0d2e088fd20db7d5b8f7b02bef60cd1e987ba3 Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Tue, 13 Oct 2009 15:02:45 -0400 Subject: clean up temp files when done Due to the logic between cleaning up threads and deleting temp files, the temp files were never deleted. Signed-off-by: Steven Rostedt --- trace-cmd.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/trace-cmd.c b/trace-cmd.c index 25e9692..5080f98 100644 --- a/trace-cmd.c +++ b/trace-cmd.c @@ -91,9 +91,10 @@ static void kill_threads(void) return; for (i = 0; i < cpu_count; i++) { - if (pids[i]) { + if (pids[i] > 0) { kill(pids[i], SIGKILL); delete_temp_file(i); + pids[i] = 0; } } } @@ -106,8 +107,11 @@ static void delete_thread_data(void) return; for (i = 0; i < cpu_count; i++) { - if (pids[i]) + if (pids[i]) { delete_temp_file(i); + if (pids[i] < 0) + pids[i] = 0; + } } } @@ -119,10 +123,10 @@ static void stop_threads(void) return; for (i = 0; i < cpu_count; i++) { - if (pids[i]) { + if (pids[i] > 0) { kill(pids[i], SIGINT); waitpid(pids[i], NULL, 0); - pids[i] = 0; + pids[i] = -1; } } } -- cgit v1.2.2