2
0
mirror of https://github.com/wolfpld/tracy synced 2026-01-19 04:52:09 +00:00

Handle SIGINT.

This allows to send the remaining data to the server, before profiled
application exits.
This commit is contained in:
Bartosz Taudul
2018-12-29 01:24:49 +01:00
parent 5cbe2c6ae5
commit 8a2894f6e6

View File

@@ -645,12 +645,16 @@ static void CrashHandler( int signal, siginfo_t* info, void* ucontext )
break; break;
} }
break; break;
case SIGINT:
strcpy( msgPtr, "User interrupt.\n" );
while( *msgPtr ) msgPtr++;
break;
default: default:
abort(); abort();
} }
while( *msgPtr ) msgPtr++; while( *msgPtr ) msgPtr++;
if( signal != SIGPIPE ) if( signal != SIGPIPE && signal != SIGINT )
{ {
strcpy( msgPtr, "Fault address: 0x" ); strcpy( msgPtr, "Fault address: 0x" );
while( *msgPtr ) msgPtr++; while( *msgPtr ) msgPtr++;
@@ -703,7 +707,14 @@ static void CrashHandler( int signal, siginfo_t* info, void* ucontext )
s_profiler.RequestShutdown(); s_profiler.RequestShutdown();
while( !s_profiler.HasShutdownFinished() ) { std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); }; while( !s_profiler.HasShutdownFinished() ) { std::this_thread::sleep_for( std::chrono::milliseconds( 10 ) ); };
abort(); if( signal == SIGINT )
{
exit( 0 );
}
else
{
abort();
}
} }
#endif #endif
@@ -867,6 +878,7 @@ Profiler::Profiler()
sigaction( SIGSEGV, &crashHandler, nullptr ); sigaction( SIGSEGV, &crashHandler, nullptr );
sigaction( SIGPIPE, &crashHandler, nullptr ); sigaction( SIGPIPE, &crashHandler, nullptr );
sigaction( SIGBUS, &crashHandler, nullptr ); sigaction( SIGBUS, &crashHandler, nullptr );
sigaction( SIGINT, &crashHandler, nullptr );
#endif #endif
#ifdef TRACY_HAS_CALLSTACK #ifdef TRACY_HAS_CALLSTACK