From 3f236b7e914efa412ccedf562a7d92a2b69b7ec9 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 3 Apr 2020 02:00:07 +0200 Subject: [PATCH] Handle ^C in capture utility on windows. --- capture/src/capture.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/capture/src/capture.cpp b/capture/src/capture.cpp index d2c8da0f..341f8c02 100644 --- a/capture/src/capture.cpp +++ b/capture/src/capture.cpp @@ -17,16 +17,13 @@ #include "../../server/TracyWorker.hpp" #include "getopt.h" -#ifndef _MSC_VER -struct sigaction oldsigint; + bool disconnect = false; void SigInt( int ) { disconnect = true; } -#endif - void Usage() { @@ -95,8 +92,10 @@ int main( int argc, char** argv ) while( !worker.HasData() ) std::this_thread::sleep_for( std::chrono::milliseconds( 100 ) ); printf( "\nQueue delay: %s\nTimer resolution: %s\n", tracy::TimeToString( worker.GetDelay() ), tracy::TimeToString( worker.GetResolution() ) ); -#ifndef _MSC_VER - struct sigaction sigint; +#ifdef _WIN32 + signal( SIGINT, SigInt ); +#else + struct sigaction sigint, oldsigint; memset( &sigint, 0, sizeof( sigint ) ); sigint.sa_handler = SigInt; sigaction( SIGINT, &sigint, &oldsigint ); @@ -107,13 +106,11 @@ int main( int argc, char** argv ) const auto t0 = std::chrono::high_resolution_clock::now(); while( worker.IsConnected() ) { -#ifndef _MSC_VER if( disconnect ) { worker.Disconnect(); disconnect = false; } -#endif lock.lock(); const auto mbps = worker.GetMbpsData().back();