2025-04-03 16:01:43 +03:00
|
|
|
package agentssh
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2025-06-30 22:06:05 +04:00
|
|
|
"os"
|
2025-04-03 16:01:43 +03:00
|
|
|
"syscall"
|
|
|
|
|
|
|
|
|
|
"cdr.dev/slog"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func cmdSysProcAttr() *syscall.SysProcAttr {
|
|
|
|
|
return &syscall.SysProcAttr{}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-30 22:06:05 +04:00
|
|
|
func cmdCancel(logger slog.Logger, p *os.Process) error {
|
|
|
|
|
logger.Debug(context.Background(), "cmdCancel: killing process", slog.F("pid", p.Pid))
|
|
|
|
|
// Windows doesn't support sending signals to process groups, so we
|
|
|
|
|
// have to kill the process directly. In the future, we may want to
|
|
|
|
|
// implement a more sophisticated solution for process groups on
|
|
|
|
|
// Windows, but for now, this is a simple way to ensure that the
|
|
|
|
|
// process is terminated when the context is cancelled.
|
|
|
|
|
return p.Kill()
|
2025-04-03 16:01:43 +03:00
|
|
|
}
|