<commit_before>/************************************************************************************
**  
* @copyright (c) 2013-2100, ChengDu Duyer Technology Co., LTD. All Right Reserved.
*
*************************************************************************************/
/**
* @file	    g_process.cpp
* @version     
* @brief      
* @author   duye
* @date     2014-09-28
* @note 
*
*  1. 2014-09-28 duye Created this file
* 
*/
#include <signal.h>
#include <g_process.h>

namespace gsys {

ProcessSysCallback::ProcessSysCallback()
{
    // segmentation fault
    signal(SIGSEGV, signalHandlerCallback);
	
    // ctrl + c
    signal(SIGINT, signalHandlerCallback);
}

ProcessMonitor* ProcessSysCallback::m_processMonitor = nullptr;

ProcessSysCallback::~ProcessSysCallback() {}

void ProcessSysCallback::registProcessMonitor(ProcessMonitor* process_monitor)
{
    m_processMonitor = process_monitor;
}

void ProcessSysCallback::signalHandlerCallback(const GInt32 sig)
{
    if (m_processMonitor != nullptr)
    {
        m_processMonitor->signalHandler(sig);
    }
}

ProcessMonitor::ProcessMonitor()
{
    m_processSysCallback.registProcessMonitor(this);
}

ProcessMonitor::~ProcessMonitor()
{
    m_processMonitorList.clear();
}

ProcessMonitor& ProcessMonitor::getInstance()
{
    static ProcessMonitor process_monitor;
    return process_monitor;
}

void ProcessMonitor::addMonitor(ProcessMonitorInterface* monitor)
{
    m_processMonitorList.push_back(monitor);
}

void ProcessMonitor::removeMonitor(ProcessMonitorInterface* monitor)
{
    ProcessMonitorList::iterator iter = m_processMonitorList.begin();
    for (; iter != m_processMonitorList.end(); ++iter)
    {
        if (monitor == *iter)
        {
            m_processMonitorList.erase(iter);
            break;
        }
    }    
}

void ProcessMonitor::signalHandler(const GInt32 sig)
{
    ProcessMonitorList::iterator iter = m_processMonitorList.begin();
    for (; iter != m_processMonitorList.end(); ++iter)
    {
        (*iter)->onSegmentationFault(sig);
        (*iter)->onCtrlC(sig);
    }    
}

}
<commit_msg>Update g_process.cpp<commit_after>/************************************************************************************
**  
* @copyright (c) 2013-2100, ChengDu Duyer Technology Co., LTD. All Right Reserved.
*
*************************************************************************************/
/**
* @file	    g_process.cpp
* @version     
* @brief      
* @author   duye
* @date     2014-09-28
* @note 
*
*  1. 2014-09-28 duye Created this file
* 
*/
#include <signal.h>
#include <g_process.h>

namespace gsys {

ProcessSysCallback::ProcessSysCallback()
{
    // segmentation fault
    signal(SIGSEGV, signalHandlerCallback);
	
    // ctrl + c
    signal(SIGINT, signalHandlerCallback);
}

ProcessMonitor* ProcessSysCallback::m_processMonitor = nullptr;

ProcessSysCallback::~ProcessSysCallback() {}

void ProcessSysCallback::registProcessMonitor(ProcessMonitor* process_monitor)
{
    m_processMonitor = process_monitor;
}

void ProcessSysCallback::signalHandlerCallback(const GInt32 sig)
{
    if (m_processMonitor != nullptr)
    {
        m_processMonitor->signalHandler(sig);
    }
}

ProcessMonitor::ProcessMonitor()
{
    m_processSysCallback.registProcessMonitor(this);
}

ProcessMonitor::~ProcessMonitor()
{
    m_processObserverList.clear();
}

ProcessMonitor& ProcessMonitor::getInstance()
{
    static ProcessMonitor process_monitor;
    return process_monitor;
}

void ProcessMonitor::addObserver(ProcessMonitorObserver* observer)
{
    ProcessObserverList::iterator iter = m_processObserverList.begin();
    for (; iter != m_processObserverList.end(); ++iter)
    {
        if (observer == *iter)
        {
			return;
        }
    }   
    
    m_processObserverList.push_back(observer);
}

void ProcessMonitor::removeObserver(ProcessMonitorObserver* observer)
{
    ProcessObserverList::iterator iter = m_processObserverList.begin();
    for (; iter != m_processObserverList.end(); ++iter)
    {
        if (observer == *iter)
        {
            m_processObserverList.erase(iter);
            break;
        }
    }    
}

void ProcessMonitor::signalHandler(const GInt32 sig)
{
    ProcessObserverList::iterator iter = m_processObserverList.begin();
    for (; iter != m_processObserverList.end(); ++iter)
    {
        (*iter)->onSegmentationFault(sig);
        (*iter)->onCtrlC(sig);
    }    
}

}

{'fraction_non_alphanumeric': 0.18854685377999095, 'fraction_numerical': 0.013128112267994568, 'mean_word_length': 4.108670520231214, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4717236', 'n_tokens_mistral': 1316, 'n_tokens_neox': 1249, 'n_words': 216}