Handle ^C in capture utility on windows.

This commit is contained in:
Bartosz Taudul 2020-04-03 02:00:07 +02:00
parent a11b52d94f
commit 3f236b7e91

View File

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