Skip to content

command: Fix Goroutines sticking around until context cancellation

Patrick Steinhardt requested to merge pks-command-exit-goroutine-early into master

When spawning a process via the command package we always make sure to start a Goroutine that waits for the context to be done so that it can reap the process's state. This is required so that we can be sure there is no resource leak. The downside of this approach is that the Goroutine will stay around until the context is cancelled though, and in case we are forced to spawn multiple commands in a single RPC request this cost may add up.

Fix this RPC-scoped resource leak by exiting the Goroutine early in case Wait() has been explicitly called.

Closes #4188 (closed)

Edited by Patrick Steinhardt

Merge request reports

Loading