<commit_before>#include <pthread.h>
#include <signal.h>
#include <string.h>
#include "libcmm.h"
#include "common.h"
#include "signals.h"

#include "tbb/concurrent_hash_map.h"
using tbb::concurrent_hash_map;

typedef concurrent_hash_map<pthread_t, int, 
                            IntegerHashCompare<pthread_t> > ThreadIdMap;
static ThreadIdMap selecting_threads;

static void
select_signal_handler(int signum)
{
    /* nothin' to do... */
}

void signals_init()
{
    struct sigaction actignore, act;
    memset(&act, 0, sizeof(act));
    memset(&actignore, 0, sizeof(actignore));
    act.sa_handler = select_signal_handler;
    sigaction(CMM_SELECT_SIGNAL, &act, NULL);
}

static void register_selecting_thread()
{
    pthread_t tid = pthread_self();
    (void)selecting_threads.insert(ThreadIdMap::value_type(tid, 0));
}

void unblock_select_signals()
{
    sigset_t sigset;
    sigemptyset(&sigset);
    sigaddset(&sigset, CMM_SELECT_SIGNAL);
    pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
    
    register_selecting_thread();
}<commit_msg>Ignore SIGPIPE.  Should change this to only apply to the internal threads.<commit_after>#include <pthread.h>
#include <signal.h>
#include <string.h>
#include "libcmm.h"
#include "common.h"
#include "signals.h"

#include "tbb/concurrent_hash_map.h"
using tbb::concurrent_hash_map;

typedef concurrent_hash_map<pthread_t, int, 
                            IntegerHashCompare<pthread_t> > ThreadIdMap;
static ThreadIdMap selecting_threads;

static void
select_signal_handler(int signum)
{
    /* nothin' to do... */
}

void signals_init()
{
    struct sigaction actignore, act;
    memset(&act, 0, sizeof(act));
    memset(&actignore, 0, sizeof(actignore));
    act.sa_handler = select_signal_handler;
    sigaction(CMM_SELECT_SIGNAL, &act, NULL);
    
    signal(SIGPIPE, SIG_IGN);
}

static void register_selecting_thread()
{
    pthread_t tid = pthread_self();
    (void)selecting_threads.insert(ThreadIdMap::value_type(tid, 0));
}

void unblock_select_signals()
{
    sigset_t sigset;
    sigemptyset(&sigset);
    sigaddset(&sigset, CMM_SELECT_SIGNAL);
    pthread_sigmask(SIG_UNBLOCK, &sigset, NULL);
    
    register_selecting_thread();
}
{'fraction_non_alphanumeric': 0.11963470319634703, 'fraction_numerical': 0.0027397260273972603, 'mean_word_length': 4.505025125628141, 'pattern_counts': {'":': 0, '<': 13, '<?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': '1006702', 'n_tokens_mistral': 784, 'n_tokens_neox': 764, 'n_words': 147}