fix: use a timer instead of a time.After to avoid memory leaks

This commit is contained in:
Juanadelacuesta
2025-04-23 16:26:46 +02:00
parent 38c27b7e7f
commit b47b962439

View File

@@ -993,11 +993,13 @@ func (c *Command) terminateGracefully(signalCh chan os.Signal, sdSock io.Writer)
close(gracefulCh)
}()
delay := time.NewTimer(gracefulTimeout)
// Wait for leave or another signal
select {
case <-signalCh:
return 1
case <-time.After(gracefulTimeout):
case <-delay.C:
return 1
case <-gracefulCh:
}