If context is canceled before the process is ready then kill goroutine returns early because there is nothing to kill. But the process may still start after this and in that case remain running without cancellation. Fix is to skip cancellation only if the run goroutine is ended, as then the process will not be started.
If context is canceled before the process is ready then kill goroutine returns early because there is nothing to kill. But the process may still start after this and in that case remain running without cancellation. Fix is to skip cancellation only if the run goroutine is ended, as then the process will not be started.