Skip to content

Don't launch commands with context canceled

Sami Hiltunen requested to merge smh-ctx-canceled-dont-start into master

The command package has a race with goroutine reaping when context is canceled command execution. This is triggered currently even if the context is canceled before starting a command as context error is not checked prior to launching. Go's CommandContext would not launch a command with a canceled context but we can't use it for now as we can't customize the signal sent on finishing. For now, fix this case by checking the context before creating a new command so we don't create commands if the context is already canceled. This still doesn't fix the actual race as the context could be canceled after this check. However, it helps make test more deterministic as they are protected from the race if they test scenarios where context is already canceled prior to launching a command.

Related to: #5021 (closed)
Closes: #5020 (closed)

Merge request reports