Files
coder/agent/agentscripts/agentscripts_other.go
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

24 lines
477 B
Go
Raw Normal View History

2023-09-25 16:47:17 -05:00
//go:build !windows
package agentscripts
import (
"context"
2023-09-25 16:47:17 -05:00
"os/exec"
"syscall"
"cdr.dev/slog"
2023-09-25 16:47:17 -05:00
)
func cmdSysProcAttr() *syscall.SysProcAttr {
return &syscall.SysProcAttr{
Setsid: true,
}
}
func cmdCancel(ctx context.Context, logger slog.Logger, cmd *exec.Cmd) func() error {
2023-09-25 16:47:17 -05:00
return func() error {
logger.Debug(ctx, "cmdCancel: sending SIGHUP to process and children", slog.F("pid", cmd.Process.Pid))
2023-09-25 16:47:17 -05:00
return syscall.Kill(-cmd.Process.Pid, syscall.SIGHUP)
}
}