<commit_before>package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"syscall"
	"time"
)

// Waits up to a minute for all processes to die.
func waitForDeath() error {
	for i := 0; i < 30; i++ {
		pids, err := getAllProcesses()
		if err != nil {
			return err
		}
		if len(pids) == 0 {
			return nil
		}

		fmt.Fprintf(os.Stderr, "Waiting for processes to die (%d processes left)..\n", len(pids))
		time.Sleep(2 * time.Second)
	}
	return fmt.Errorf("processes did not die after a minute")
}

// KillAll processes on the system.
func KillAll() {
	fmt.Fprintf(os.Stderr, "Killing system processes..\n")
	// Try to send a sigterm
	pids, err := getAllProcesses()
	if err != nil {
		log.Println(err)
		return
	}
	for _, proc := range pids {
		proc.Signal(syscall.SIGTERM)
	}

	if err := waitForDeath(); err != nil {
		log.Println(err)
	}
	// They didn't respond to sigterm after a minute, so be mean and send a SIGKILL
	pids, _ = getAllProcesses()
	for _, proc := range pids {
		proc.Signal(syscall.SIGKILL)
	}
	if len(pids) > 0 {
		fmt.Fprintf(os.Stderr, "Sent kill signal to %d processes that didn't respond to term..\n", len(pids))
		time.Sleep(2 * time.Second)<commit_msg>When shutdown print processes names to waiting message<commit_after>package main

import (
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"syscall"
	"time"
	"github.com/mitchellh/go-ps"
)

// Waits up to a minute for all processes to die.
func waitForDeath() error {
	for i := 0; i < 30; i++ {
		pids, err := getAllProcesses()
		if err != nil {
			return err
		}
		if len(pids) == 0 {
			return nil
		}

		fmt.Fprintf(os.Stderr, "Waiting for processes to die (%d processes left)..\n", len(pids))

		for _, pid := range pids {
			p, err := ps.FindProcess(pid.Pid)
			if err != nil {
				return err
			}
			fmt.Fprintf(os.Stderr, "PID %d with name %s is still alive.\n", p.Pid(), p.Executable())
		}

		time.Sleep(2 * time.Second)
	}
	return fmt.Errorf("processes did not die after a minute")
}

// KillAll processes on the system.
func KillAll() {
	fmt.Fprintf(os.Stderr, "Killing system processes..\n")
	// Try to send a sigterm
	pids, err := getAllProcesses()
	if err != nil {
		log.Println(err)
		return
	}
	for _, proc := range pids {
		proc.Signal(syscall.SIGTERM)
	}

	if err := waitForDeath(); err != nil {
		log.Println(err)
	}
	// They didn't respond to sigterm after a minute, so be mean and send a SIGKILL
	pids, _ = getAllProcesses()
	for _, proc := range pids {
		proc.Signal(syscall.SIGKILL)
	}
	if len(pids) > 0 {
		fmt.Fprintf(os.Stderr, "Sent kill signal to %d processes that didn't respond to term..\n", len(pids))
		time.Sleep(2 * time.Second)
{'fraction_non_alphanumeric': 0.14334341906202724, 'fraction_numerical': 0.00529500756429652, 'mean_word_length': 3.1917591125198097, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6773930', 'n_tokens_mistral': 1095, 'n_tokens_neox': 996, 'n_words': 304}