From: José Fonseca Date: Thu, 22 Sep 2011 16:49:24 +0000 (+0100) Subject: Install the signal handlers as early as possible, X-Git-Url: https://git.notmuchmail.org/git?a=commitdiff_plain;h=9acebf9ca871b3f9a5dfba0ac4f3a9c562c12ff0;p=apitrace Install the signal handlers as early as possible, To prevent interfering with the application's signal handling. --- diff --git a/common/trace_local_writer.cpp b/common/trace_local_writer.cpp index ea6c111..e625f2e 100644 --- a/common/trace_local_writer.cpp +++ b/common/trace_local_writer.cpp @@ -41,14 +41,17 @@ namespace Trace { static void exceptionCallback(void) { - OS::DebugMessage("apitrace: flushing trace due to an exception\n"); localWriter.flush(); } LocalWriter::LocalWriter() : acquired(0) -{} +{ + // Install the signal handlers as early as possible, to prevent + // interfering with the application's signal handling. + OS::SetExceptionCallback(exceptionCallback); +} LocalWriter::~LocalWriter() { @@ -96,8 +99,6 @@ LocalWriter::open(void) { Writer::open(szFileName); - OS::SetExceptionCallback(exceptionCallback); - #if 0 // For debugging the exception handler *((int *)0) = 0; @@ -142,6 +143,7 @@ void LocalWriter::flush(void) { if (!acquired) { OS::AcquireMutex(); if (m_file->isOpened()) { + OS::DebugMessage("apitrace: flushing trace due to an exception\n"); m_file->flush(); } OS::ReleaseMutex();