mirror of
https://github.com/coder/coder.git
synced 2026-11-12 04:32:47 +08:00
Fix hanging workspace shutdowns caused by orphaned SSH child processes. Key changes: - Create process groups for non-PTY SSH sessions - Send SIGHUP to entire process group for proper termination - Add 5-second timeout to prevent indefinite blocking Fixes #17108
22 lines
416 B
Go
22 lines
416 B
Go
package agentssh
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"os/exec"
|
|
"syscall"
|
|
|
|
"cdr.dev/slog"
|
|
)
|
|
|
|
func cmdSysProcAttr() *syscall.SysProcAttr {
|
|
return &syscall.SysProcAttr{}
|
|
}
|
|
|
|
func cmdCancel(ctx context.Context, logger slog.Logger, cmd *exec.Cmd) func() error {
|
|
return func() error {
|
|
logger.Debug(ctx, "cmdCancel: sending interrupt to process", slog.F("pid", cmd.Process.Pid))
|
|
return cmd.Process.Signal(os.Interrupt)
|
|
}
|
|
}
|