<commit_before>import { ChildProcess } from "child_process";

/**
 * Write the stdin into the child process
 * @param proc Child process refrence
 * @param stdin stdin string
 */
export function writeToStdin(proc: ChildProcess, stdin: string): void {
    if (stdin) {
        proc.stdin.write(stdin + '\r\n', err => {
            if (!err) {
                proc.stdin.end();
            }
        });
        proc.stdin.on("error", err => {
            // Ignore input if stream is already closed
            return;
        });
    }
}<commit_msg>Fxing error that caused application to hang in case the process has finished and some input is pass to stdin<commit_after>import { ChildProcess } from "child_process";

/**
 * Write the stdin into the child process
 * @param proc Child process refrence
 * @param stdin stdin string
 */
export function writeToStdin(proc: ChildProcess, stdin: string): void {
    if (stdin) {
        proc.stdin.on("error", err => {
            // Ignore input if stream is already closed
            return;
        });
        proc.stdin.write(stdin + '\r\n', err => {
            if (!err) {
                proc.stdin.end();
            }
        });
    }
}
{'fraction_non_alphanumeric': 0.1173512154233026, 'fraction_numerical': 0.0, 'mean_word_length': 2.045918367346939, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '5479559', 'n_tokens_mistral': 343, 'n_tokens_neox': 339, 'n_words': 109}