Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In go2rtc 1.9.4 it is easy to have hangs on exec processes, especially if they spawn child processes, due to a race condition caused by the fact that closer calls cmd.Wait() for RTSP sessions even though cmd.Wait() has already been called in handleRTSP. As far as I can tell, callling Wait() twice is bad practice and the behavior of doing so is undefined.
This small patch fixes the issue by passing in the existing channel from handleRTSP to the closer so that it can share the same wait() instead of attempting to call it a second time. For the handlePipe case, there is no initial call to cmd.Wait(), so the code behaves as previous.
I've tested various killsignals and killtimeout and this fixes all persistent hang conditions. There is still a scenario where, sigkill may kill the parent but the secondary process keeps the producer stream alive. I somewhat wonder if it should always return after sigkill, perhaps after a short timeout, since that should hard kill the parent and clearly the goal at that point is to stop the stream immediately, but I'm guessing this is a rare occurrence.
#1243