mirror of
https://github.com/rclone/rclone.git
synced 2025-12-11 22:14:05 +01:00
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>
This commit is contained in:
@@ -181,10 +181,8 @@ func (s *sshSessionExternal) Wait() error {
|
|||||||
// Use sync.Once to ensure we only wait for the process once
|
// Use sync.Once to ensure we only wait for the process once
|
||||||
// This prevents zombie processes that occur when Wait() is called multiple times
|
// This prevents zombie processes that occur when Wait() is called multiple times
|
||||||
s.waitOnce.Do(func() {
|
s.waitOnce.Do(func() {
|
||||||
if s.exited() {
|
// Always call cmd.Wait() to properly reap the process
|
||||||
s.waitErr = nil
|
// even if it has already exited
|
||||||
return
|
|
||||||
}
|
|
||||||
s.waitErr = s.cmd.Wait()
|
s.waitErr = s.cmd.Wait()
|
||||||
if s.waitErr == nil {
|
if s.waitErr == nil {
|
||||||
fs.Debugf(s.f, "ssh external: command exited OK")
|
fs.Debugf(s.f, "ssh external: command exited OK")
|
||||||
|
|||||||
Reference in New Issue
Block a user