From 707b09141e49ae9de29b5358f6f5a0fd09ce79af Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 2 Sep 2005 13:47:23 +0200 Subject: [PATCH] [PATCH] Fix the stop trace logic to not attempt to stop it twice --- blktrace.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/blktrace.c b/blktrace.c index 78cdc85..c568d0f 100644 --- a/blktrace.c +++ b/blktrace.c @@ -173,10 +173,13 @@ static int start_trace(char *dev) static void stop_trace(void) { - if (ioctl(devfd, BLKSTOPTRACE) < 0) - perror("BLKSTOPTRACE"); + if (trace_started) { + if (ioctl(devfd, BLKSTOPTRACE) < 0) + perror("BLKSTOPTRACE"); - close(devfd); + close(devfd); + trace_started = 0; + } } static void extract_data(struct thread_information *tip, @@ -352,12 +355,6 @@ void handle_sigint(int sig) done = 1; } -void stop_trace_on_exit(void) -{ - if (trace_started) - stop_trace(); -} - int main(int argc, char *argv[]) { static char default_relay_path[] = "/relay"; @@ -447,7 +444,7 @@ int main(int argc, char *argv[]) signal(SIGHUP, handle_sigint); signal(SIGTERM, handle_sigint); - atexit(stop_trace_on_exit); + atexit(stop_trace); while (!is_done()) sleep(1); -- 2.25.1