<commit_before>package immortal

import (
	"fmt"
	"os"
	"os/exec"
	"strconv"
	"syscall"
	"time"
)

// Process interface
type Process interface {
	Kill() error
	Pid() int
	Signal(sig syscall.Signal) error
	Start() (*process, error)
}

type process struct {
	*Config
	Logger
	LoggerStderr Logger
	cmd          *exec.Cmd
	errch        chan error
	quit         chan struct{}
	sTime, eTime time.Time
}

// SetEnv set environment variables - If the Cmd.Env contains duplicate
// environment keys, only the last value in the slice for each duplicate
// key is used.
func (p *process) SetEnv(env []string) {
	if p.Env != nil {
		for k, v := range p.Env {
			env = append(env, fmt.Sprintf("%s=%s", k, v))
		}
		p.cmd.Env = env
	}
}

// SetsysProcAttr - set process owner (run on behalf)
func (p *process) SetsysProcAttr() error {
	sysProcAttr := &syscall.SysProcAttr{
		Setpgid: true, // Set process group ID to Pgid, or, if Pgid == 0, to new pid.
		Pgid:    0,    // Child's process group ID if Setpgid.<commit_msg>comment<commit_after>package immortal

import (
	"fmt"
	"os"
	"os/exec"
	"strconv"
	"syscall"
	"time"
)

// Process interface
type Process interface {
	Kill() error
	Pid() int
	Signal(sig syscall.Signal) error
	Start() (*process, error)
}

type process struct {
	*Config
	Logger
	LoggerStderr Logger
	cmd          *exec.Cmd
	errch        chan error
	quit         chan struct{}
	sTime, eTime time.Time
}

// SetEnv set environment variables - If the Cmd.Env contains duplicate
// environment keys, only the last value in the slice for each duplicate
// key is used.
func (p *process) SetEnv(env []string) {
	if p.Env != nil {
		for k, v := range p.Env {
			env = append(env, fmt.Sprintf("%s=%s", k, v))
		}
		p.cmd.Env = env
	}
}

// SetsysProcAttr - set process group ID and owner (run on behalf)
func (p *process) SetsysProcAttr() error {
	sysProcAttr := &syscall.SysProcAttr{
		Setpgid: true, // Set process group ID to Pgid, or, if Pgid == 0, to new pid.
		Pgid:    0,    // Child's process group ID if Setpgid.
{'fraction_non_alphanumeric': 0.12172191984166254, 'fraction_numerical': 0.0019792182088075212, 'mean_word_length': 3.044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3332708', 'n_tokens_mistral': 745, 'n_tokens_neox': 696, 'n_words': 248}