2025-04-03 16:01:43 +03:00
|
|
|
//go:build !windows
|
|
|
|
|
|
|
|
|
|
package agentssh
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-06-30 22:06:05 +04:00
|
|
|
"os"
|
2025-04-03 16:01:43 +03:00
|
|
|
"syscall"
|
|
|
|
|
|
2026-01-08 10:29:41 +04:00
|
|
|
"cdr.dev/slog/v3"
|
2025-04-03 16:01:43 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func cmdSysProcAttr() *syscall.SysProcAttr {
|
|
|
|
|
return &syscall.SysProcAttr{
|
|
|
|
|
Setsid: true,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-30 22:06:05 +04:00
|
|
|
func cmdCancel(logger slog.Logger, p *os.Process) error {
|
|
|
|
|
logger.Debug(context.Background(), "cmdCancel: sending SIGHUP to process and children", slog.F("pid", p.Pid))
|
|
|
|
|
return syscall.Kill(-p.Pid, syscall.SIGHUP)
|
2025-04-03 16:01:43 +03:00
|
|
|
}
|