src/ProcDumpConfiguration.c
//--------------------------------------------------------------------
//
// CreateTriggerThreads - Create each of the threads that will be running as a trigger 
//
//--------------------------------------------------------------------
Create each of the threads that will be running as a trigger
Create each of the threads that will be running as a trigger
int CreateTriggerThreads(struct ProcDumpConfiguration *self)
{    
    int rc = 0;
    self->nThreads = 0;
    if((rc=sigemptyset (&sig_set)) < 0)
    {
        Trace("CreateTriggerThreads: sigemptyset failed.");
        return rc;
    }
    if((rc=sigaddset (&sig_set, SIGINT)) < 0)
    {
        Trace("CreateTriggerThreads: sigaddset failed.");
        return rc;
    }
    if((rc=sigaddset (&sig_set, SIGTERM)) < 0)
    {
        Trace("CreateTriggerThreads: sigaddset failed.");
        return rc;
    }
    if((rc = pthread_sigmask (SIG_BLOCK, &sig_set, NULL)) != 0)
    {
        Trace("CreateTriggerThreads: pthread_sigmask failed.");
        return rc;
    }
    if (self->CpuThreshold != -1) {
        if ((rc = pthread_create(&self->Threads[self->nThreads++], NULL, CpuMonitoringThread, (void *)self)) != 0) {
            Trace("CreateTriggerThreads: failed to create CpuThread.");            
            return rc;
        }
    }
    if (self->MemoryThreshold != -1) {
        if ((rc = pthread_create(&self->Threads[self->nThreads++], NULL, CommitMonitoringThread, (void *)self)) != 0) {
            Trace("CreateTriggerThreads: failed to create CommitThread.");            
            return rc;
        }
    }
    if (self->ThreadThreshold != -1) {
        if ((rc = pthread_create(&self->Threads[self->nThreads++], NULL, ThreadCountMonitoringThread, (void *)self)) != 0) {
            Trace("CreateTriggerThreads: failed to create ThreadThread.");            
            return rc;
        }
    }
    if (self->FileDescriptorThreshold != -1) {
        if ((rc = pthread_create(&self->Threads[self->nThreads++], NULL, FileDescriptorCountMonitoringThread, (void *)self)) != 0) {
            Trace("CreateTriggerThreads: failed to create FileDescriptorThread.");            
            return rc;
        }
    }
    if (self->bTimerThreshold) {
        if ((rc = pthread_create(&self->Threads[self->nThreads++], NULL, TimerThread, (void *)self)) != 0) {
            Trace("CreateTriggerThreads: failed to create TimerThread.");
            return rc;
        }
    }
    if((rc = pthread_create(&sig_thread_id, NULL, SignalThread, (void *)self))!= 0)
    {
        Trace("CreateTriggerThreads: failed to create SignalThread.");
        return rc;
    }
    return 0;
}
int CreateTriggerThreads ( struct ProcDumpConfiguration * self ) { int rc = 0 ; self -> nThreads = 0 ; if ( ( rc = sigemptyset ( & sig_set ) ) < 0 ) { Trace ( " " ) ; return rc ; } if ( ( rc = sigaddset ( & sig_set , SIGINT ) ) < 0 ) { Trace ( " " ) ; return rc ; } if ( ( rc = sigaddset ( & sig_set , SIGTERM ) ) < 0 ) { Trace ( " " ) ; return rc ; } if ( ( rc = pthread_sigmask ( SIG_BLOCK , & sig_set , NULL ) ) != 0 ) { Trace ( " " ) ; return rc ; } if ( self -> CpuThreshold != -1 ) { if ( ( rc = pthread_create ( & self -> Threads [ self -> nThreads ++ ] , NULL , CpuMonitoringThread , ( void * ) self ) ) != 0 ) { Trace ( " " ) ; return rc ; } } if ( self -> MemoryThreshold != -1 ) { if ( ( rc = pthread_create ( & self -> Threads [ self -> nThreads ++ ] , NULL , CommitMonitoringThread , ( void * ) self ) ) != 0 ) { Trace ( " " ) ; return rc ; } } if ( self -> ThreadThreshold != -1 ) { if ( ( rc = pthread_create ( & self -> Threads [ self -> nThreads ++ ] , NULL , ThreadCountMonitoringThread , ( void * ) self ) ) != 0 ) { Trace ( " " ) ; return rc ; } } if ( self -> FileDescriptorThreshold != -1 ) { if ( ( rc = pthread_create ( & self -> Threads [ self -> nThreads ++ ] , NULL , FileDescriptorCountMonitoringThread , ( void * ) self ) ) != 0 ) { Trace ( " " ) ; return rc ; } } if ( self -> bTimerThreshold ) { if ( ( rc = pthread_create ( & self -> Threads [ self -> nThreads ++ ] , NULL , TimerThread , ( void * ) self ) ) != 0 ) { Trace ( " " ) ; return rc ; } } if ( ( rc = pthread_create ( & sig_thread_id , NULL , SignalThread , ( void * ) self ) ) != 0 ) { Trace ( " " ) ; return rc ; } return 0 ; }
CreateTriggerThreads - Create each of the threads that will be running as a trigger
CreateTriggerThreads - Create each of the threads that will be running as a trigger
// create threads