Signal handler for Ctrl-C (SIGINT) Returns: None Note: This function is never called by the application but is instead passed as a function pointer to signal during initialization where it surplants the default interupt handler for the given signal.

Return TypeFunction nameArguments
voidCatchCtrlC(int32_t,)

Declared in file: hzProcess.h
Defined in file : hzProcess.cpp

Function Logic:

0:START 1:pid tid nSize cpSym pLog phz 2:unknown 3:items items items 4:unknown 5:items 6:items items items 7:items items items 8:unknown 9:items 10:items items 11:unknown 12:items 13:items 14: No text

Function body:

void CatchCtrlC (int32_t sig)
{
   //  Category: Process
   //  
   //  Signal handler for Ctrl-C (SIGINT)
   //  
   //  Arguments: 1) sig  The incoming signal.
   //  Returns: None
   //  
   //  Note: This function is never called by the application but is instead passed as a function pointer to signal during initialization where it
   //    surplants the default interupt handler for the given signal.
   hzLogger*   pLog ;          //  Current thread logger
   hzProcess*  phz ;           //  Current thread info
   void*       pvArr[1024];//  Backtrace
   char**      cpSym ;         //  Backtrace symbols
   uint32_t    pid ;           //  Process id
   uint32_t    tid ;           //  Thread id
   uint32_t    nSize ;         //  Backtrace array size
   uint32_t    nIndex ;        //  Symbols iterator
   pid = getpid() ;
   tid = pthread_self() ;
   nSize = backtrace(pvArr, 1023);
   cpSym = backtrace_symbols(pvArr, nSize);
   pLog = GetThreadLogger() ;
   phz = GetThreadInfo() ;
   if (!pLog)
   {
       printf("CatchCtrlC: %s\n", s_signals[sig]) ;
       printf("CatchCtrlC: Signal %d Process %u, thread %u\n", sig, pid, tid) ;
       printf("Stack Trace is:\n") ;
       for (nIndex = 0; nIndex < nSize ; nIndex++)
           puts(cpSym[nIndex]);;
       printf("Stack Trace end:\n") ;
       fflush(stdout);
       phz->StackTrace() ;
   }
   else
   {
       pLog->Log("CatchCtrlC: %s\n", s_signals[sig]) ;
       pLog->Out("Signal %d Process %u, thread %u\n", sig, pid, tid) ;
       pLog->Out("Stack Trace is:\n") ;
       for (nIndex = 0; nIndex < nSize ; nIndex++)
           pLog->Out("%s\n", cpSym[nIndex]) ;
       phz->StackTrace() ;
       pLog->Out("Stack Trace end:\n") ;
       //  phz->CallHistory() ;
       //  pLog->Out("Call History end:\n") ;
   }
   //  free(cpSym);
   //  re-set the signal handler again to this function for next time
   if (sig == 2)
       signal(sig, 0);
   else
       signal(sig, CatchCtrlC);
}