refactor: Project directories (#541)
Some checks failed
Build Snapshot / build-snapshot (push) Waiting to run
DevSkim / DevSkim (push) Waiting to run
Buf CI / buf (push) Has been cancelled
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Codestyle checks / codestyle (push) Has been cancelled

This commit is contained in:
James Read
2025-03-22 01:06:59 +00:00
committed by GitHub
parent b4c886d5d3
commit ff31abe66c
76 changed files with 100 additions and 73 deletions

View File

@@ -0,0 +1,25 @@
//go:build !windows
// +build !windows
package executor
import (
"context"
"os/exec"
"syscall"
)
func (e *Executor) Kill(execReq *InternalLogEntry) error {
// A negative PID means to kill the whole process group. This is *nix specific behavior.
return syscall.Kill(-execReq.Process.Pid, syscall.SIGKILL)
}
func wrapCommandInShell(ctx context.Context, finalParsedCommand string) *exec.Cmd {
cmd := exec.CommandContext(ctx, "sh", "-c", finalParsedCommand)
// This is to ensure that the process group is killed when the parent process is killed.
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
return cmd
}