From 21726702370b74fb7b5c7e95b457319ff4fc844f Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 7 Nov 2011 20:21:07 +0000 Subject: [PATCH] scheduling_recorder: Fix signal handling * The sa_flags field of the structure passed to sigaction() wasn't cleared, which resulted in the wrong type of handler function being called and the second parameter not being the expected user data. * Always check fCaughtDeadlySignal in the main loop, so the signal doesn't have to hit the _kern_system_profiler_next_buffer() call (though that's the most likely one anyway). Now scheduling_recorder can be stopped with a single Ctrl-C again. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@43219 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/bin/debug/scheduling_recorder/scheduling_recorder.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/bin/debug/scheduling_recorder/scheduling_recorder.cpp b/src/bin/debug/scheduling_recorder/scheduling_recorder.cpp index 0be34b541f..73df4880b5 100644 --- a/src/bin/debug/scheduling_recorder/scheduling_recorder.cpp +++ b/src/bin/debug/scheduling_recorder/scheduling_recorder.cpp @@ -117,6 +117,7 @@ public: // install signal handlers so we can exit gracefully struct sigaction action; action.sa_handler = (__sighandler_t)_SignalHandler; + action.sa_flags = 0; sigemptyset(&action.sa_mask); action.sa_userdata = this; if (sigaction(SIGHUP, &action, NULL) < 0 @@ -177,7 +178,7 @@ public: || _ProcessEventBuffer(bufferBase, remainingSize); } - if (quit) + if (quit || fCaughtDeadlySignal) break; // get next buffer @@ -186,11 +187,8 @@ public: &droppedEvents); if (error != B_OK) { - if (error == B_INTERRUPTED) { - if (fCaughtDeadlySignal) - break; + if (error == B_INTERRUPTED) continue; - } fprintf(stderr, "%s: Failed to get next sample buffer: %s\n", kCommandName, strerror(error));