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();