Fix goroutine leak in the nullio reader

This commit is contained in:
Maximilian Paß
2021-12-11 22:04:20 +01:00
parent c565ca217e
commit 9f0b04660f
3 changed files with 30 additions and 8 deletions

View File

@ -374,9 +374,12 @@ func (a *APIClient) executeCommandInteractivelyWithStderr(allocationID string, c
stderrExitChan := make(chan int)
go func() {
readingContext, cancel := context.WithCancel(ctx)
defer cancel()
// Catch stderr in separate execution.
exit, err := a.Execute(allocationID, ctx, stderrFifoCommand(currentNanoTime), true,
nullio.Reader{}, stderr, io.Discard)
nullio.Reader{Ctx: readingContext}, stderr, io.Discard)
if err != nil {
log.WithError(err).WithField("runner", allocationID).Warn("Stderr task finished with error")
}