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
This commit is contained in:
Ingo Weinhold
2011-11-07 20:21:07 +00:00
parent ee87d51d97
commit 2172670237
@@ -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));