agent: Fix bug with early exits during restarts (#20950)

This commit is contained in:
Anton Averchenkov
2023-06-02 09:05:13 -04:00
committed by GitHub
parent f8d1d98995
commit bc9a39a2f1

View File

@@ -320,8 +320,11 @@ func (s *Server) restartChildProcess(newEnvVars []string) error {
// race condition with ExitCh not being initialized.
go func() {
select {
case exitCode := <-proc.ExitCh():
s.childProcessExitCh <- exitCode
case exitCode, ok := <-proc.ExitCh():
// ignore ExitCh channel closures caused by our restarts
if ok {
s.childProcessExitCh <- exitCode
}
}
}()