mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
Relates to https://github.com/coder/internal/issues/329 It's currently unclear where the SIGHUP came from; adding some logging to make it more clear if it happens again in future. --------- Co-authored-by: Danny Kopping <danny@coder.com>
25 lines
477 B
Go
25 lines
477 B
Go
//go:build !windows
|
|
|
|
package agentscripts
|
|
|
|
import (
|
|
"context"
|
|
"os/exec"
|
|
"syscall"
|
|
|
|
"cdr.dev/slog"
|
|
)
|
|
|
|
func cmdSysProcAttr() *syscall.SysProcAttr {
|
|
return &syscall.SysProcAttr{
|
|
Setsid: true,
|
|
}
|
|
}
|
|
|
|
func cmdCancel(ctx context.Context, logger slog.Logger, cmd *exec.Cmd) func() error {
|
|
return func() error {
|
|
logger.Debug(ctx, "cmdCancel: sending SIGHUP to process and children", slog.F("pid", cmd.Process.Pid))
|
|
return syscall.Kill(-cmd.Process.Pid, syscall.SIGHUP)
|
|
}
|
|
}
|