mirror of
https://github.com/coder/coder.git
synced 2025-07-12 00:14:10 +00:00
(possibly temporary) fix for #18519 Matches OpenSSH for non-tty sessions, where we don't actively terminate the process. Adds explicit tracking to the SSH server for these processes so that if we are shutting down we terminate them: this ensures that we can shut down quickly to allow shutdown scripts to run. It also ensures our tests don't leak system resources.
23 lines
409 B
Go
23 lines
409 B
Go
//go:build !windows
|
|
|
|
package agentssh
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"syscall"
|
|
|
|
"cdr.dev/slog"
|
|
)
|
|
|
|
func cmdSysProcAttr() *syscall.SysProcAttr {
|
|
return &syscall.SysProcAttr{
|
|
Setsid: true,
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|