<commit_before>/**
 * This module binds cleanup handlers to the node.js process.
 */
'use strict';

const events = require('events');

const logger = require('../logger');

const POSIX = {
	SIGHUP: 1,
	SIGINT: 2,
	SIGKILL: 9,
	SIGUSR2: 31,
	SIGTERM: 15
};

module.exports = cleanup => {
    if (typeof cleanup !== 'function') {
        return;
    }

    process.on('beforeExit', () => {
        const _cleanup = cleanup();

        if (!(_cleanup instanceof Promise)) {
            return;
        }

        _cleanup.then(()=>{}, ()=>{});
    });

    process.on('dev.shutdown', () => {
        const _cleanup = cleanup();

        if (!(_cleanup instanceof Promise)) {
            return;
        }

        _cleanup
            .then(() => process.exit(128 + POSIX.SIGINT))
            .catch(err => {
                logger.error(err);
                process.exit(128 + POSIX.SIGINT);
            });
    });
        
    for (const [signal, code] of Object.entries(POSIX)) {
        process.on(signal, () => {
            const _cleanup = cleanup();

            if (!(_cleanup instanceof Promise)) {
                return;
            }

            _cleanup.then(() => process.exit(128 + code), ()=>{});
        });
    }
};
<commit_msg>Removed SIGKILL handler due to errors being thrown<commit_after>/**
 * This module binds cleanup handlers to the node.js process.
 */
'use strict';

const events = require('events');

const logger = require('../logger');

const POSIX = {
	SIGHUP: 1,
	SIGINT: 2,
	SIGUSR2: 31,
	SIGTERM: 15
};

module.exports = cleanup => {
    if (typeof cleanup !== 'function') {
        return;
    }

    process.on('beforeExit', () => {
        const _cleanup = cleanup();

        if (!(_cleanup instanceof Promise)) {
            return;
        }

        _cleanup.then(()=>{}, ()=>{});
    });

    process.on('dev.shutdown', () => {
        const _cleanup = cleanup();

        if (!(_cleanup instanceof Promise)) {
            return;
        }

        _cleanup
            .then(() => process.exit(128 + POSIX.SIGINT))
            .catch(err => {
                logger.error(err);
                process.exit(128 + POSIX.SIGINT);
            });
    });
        
    for (const [signal, code] of Object.entries(POSIX)) {
        process.on(signal, () => {
            const _cleanup = cleanup();

            if (!(_cleanup instanceof Promise)) {
                return;
            }

            _cleanup.then(() => process.exit(128 + code), ()=>{});
        });
    }
};

{'fraction_non_alphanumeric': 0.16521048451151707, 'fraction_numerical': 0.013105639396346307, 'mean_word_length': 1.7470010905125408, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '3666736', 'n_tokens_mistral': 782, 'n_tokens_neox': 722, 'n_words': 169}