From a58efc1544b49e6673c7aec89dc679417782222b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 30 Oct 2025 18:03:48 +0000 Subject: [PATCH] Simplify Wait() implementation based on code review feedback Remove unnecessary exited() check - we should always call cmd.Wait() in the sync.Once block to properly reap the process and capture its exit status. The sync.Once ensures it's only called once. Co-authored-by: ncw <536803+ncw@users.noreply.github.com> --- backend/sftp/ssh_external.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/sftp/ssh_external.go b/backend/sftp/ssh_external.go index 0193ed581..5429577eb 100644 --- a/backend/sftp/ssh_external.go +++ b/backend/sftp/ssh_external.go @@ -181,10 +181,8 @@ func (s *sshSessionExternal) Wait() error { // Use sync.Once to ensure we only wait for the process once // This prevents zombie processes that occur when Wait() is called multiple times s.waitOnce.Do(func() { - if s.exited() { - s.waitErr = nil - return - } + // Always call cmd.Wait() to properly reap the process + // even if it has already exited s.waitErr = s.cmd.Wait() if s.waitErr == nil { fs.Debugf(s.f, "ssh external: command exited OK")