-
-
Notifications
You must be signed in to change notification settings - Fork 9
π‘οΈ Sentinel: [MEDIUM] Fix Process deadlocks by reading pipes before waitUntilExit #82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -167,9 +167,9 @@ private enum OBSMediaMTXManager { | |||||||||||||||||||||||||
| which.standardOutput = outPipe | ||||||||||||||||||||||||||
| which.standardError = Pipe() | ||||||||||||||||||||||||||
| try? which.run() | ||||||||||||||||||||||||||
| let data = outPipe.fileHandleForReading.readDataToEndOfFile() | ||||||||||||||||||||||||||
| which.waitUntilExit() | ||||||||||||||||||||||||||
| if which.terminationStatus == 0 { | ||||||||||||||||||||||||||
|
Comment on lines
+170
to
172
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π©Ί Stability & Availability | π‘ Minor | β‘ Quick win
Line 169 uses Additionally, π§ Proposed fixes (lines 168-169, outside selected range)Handle the run error before reading: - try? which.run()
+ do {
+ try which.run()
+ } catch {
+ throw XCTSkip("mediamtx not found. Install with `brew install mediamtx` or set MEDIAMTX_BIN")
+ }Redirect stderr to null device: - which.standardError = Pipe()
+ which.standardError = FileHandle.nullDeviceπ Committable suggestion
Suggested change
π€ Prompt for AI Agents |
||||||||||||||||||||||||||
| let data = outPipe.fileHandleForReading.readDataToEndOfFile() | ||||||||||||||||||||||||||
| if let path = String(data: data, encoding: .utf8)? | ||||||||||||||||||||||||||
| .trimmingCharacters(in: .whitespacesAndNewlines), | ||||||||||||||||||||||||||
| !path.isEmpty, | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π©Ί Stability & Availability | π‘ Minor | β‘ Quick win
Stderr pipe not drained β same deadlock risk remains for stderr.
The stdout read is correctly reordered before
waitUntilExit(), butprocess.standardError(line 1400) is set to aPipe()that is never read. If the tailscale command writes more than the OS pipe buffer (~64KB) to stderr, the child blocks on the write while the parent blocks onreadDataToEndOfFile()orwaitUntilExit()β the exact deadlock this PR aims to prevent.Since stderr output is not used here, redirect it to
FileHandle.nullDevice, matching the pattern already used inchildPIDsin AutomationExecutor.swift.π§ Proposed fix (line 1400, outside selected range)
π Committable suggestion
π€ Prompt for AI Agents