go-basher icon indicating copy to clipboard operation
go-basher copied to clipboard

goroutine leak in Context.Run?

Open ain-valtin opened this issue 4 years ago • 3 comments

It seems there is a goroutine leak in Context.Run: https://github.com/progrium/go-basher/blob/master/basher.go#L267 goroutine is launched which iterates over signals chan. But the chan is never closed, so the routine never exits... shouldn't there be something like

defer func() {
   signal.Stop(signals)
   close(signals)
}()

after signal.Notify(signals) call?

ain-valtin avatar Jun 11 '20 08:06 ain-valtin

Do you think https://github.com/progrium/go-basher/pull/23 would resolve it?

josegonzalez avatar Jun 11 '20 19:06 josegonzalez

No - the goroutine will still stay around until the signals chan is closed (which currently never happens).

ain-valtin avatar Jun 12 '20 06:06 ain-valtin

Hmmm I think that makes sense - @progrium thoughts? - and would take a PR :)

josegonzalez avatar Dec 05 '20 06:12 josegonzalez