]> git.cworth.org Git - apitrace/blobdiff - os_win32.cpp
Make sure that the traces are always complete.
[apitrace] / os_win32.cpp
index 6cddc552681db55863e1eaf01f1f1baac070c2ed..90ce8d3a74a41a5a660cc71547d27898d0d834e1 100644 (file)
@@ -24,6 +24,7 @@
  **************************************************************************/
 
 #include <windows.h>
+#include <signal.h>
 #include <string.h>
 #include <stdio.h>
 
@@ -99,11 +100,18 @@ DebugMessage(const char *format, ...)
     va_end(ap);
 
     OutputDebugStringA(buf);
+
+    /*
+     * Also write the message to stderr, when a debugger is not present (to
+     * avoid duplicate messages in command line debuggers).
+     */
+#if _WIN32_WINNT > 0x0400
     if (!IsDebuggerPresent()) {
         fflush(stdout);
         fputs(buf, stderr);
         fflush(stderr);
     }
+#endif
 }
 
 long long GetTime(void)
@@ -126,4 +134,13 @@ Abort(void)
 #endif
 }
 
+void
+CatchInterrupts(void (*func)(int))
+{
+    signal(SIGINT, func);
+    signal(SIGHUP, func);
+    signal(SIGTERM, func);
+}
+
+
 } /* namespace OS */