mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-24 19:35:28 -06:00
1257279de6
Writing to a pipe whose reader has already exited raises SIGPIPE, which kills the whole process instead of throwing. MacNodeHostWorker already guarded its stdin pipe with F_SETNOSIGPIPE; the codex App Server client and the MLX TTS helper transport did not, so a child exiting mid-write could take down the app. Suppressing the signal exposed that an undelivered App Server request write was reported as appServerUnavailable even though the frame was provably never sent, so it now requeues once onto a fresh child instead of failing the caller. Test-side pipe write ends whose readers are spawned children (or a readability handler that can close the pipe mid-test) get the same suppression so a racing reader exit fails the assertion instead of killing swiftpm-testing-helper with signal 13, which is what caused the macos-swift CI lane's intermittent unrelated-test crashes (e.g. PR #126559, run 32341197738 job 96340683947).
18 lines
639 B
Swift
18 lines
639 B
Swift
import Foundation
|
|
import Testing
|
|
|
|
struct TestProcessSupportPipeTests {
|
|
@Test func `suppressed write end reports EPIPE instead of killing the harness`() throws {
|
|
let pipe = Pipe()
|
|
try TestProcessSupport.suppressSIGPIPE(pipe.fileHandleForWriting)
|
|
try pipe.fileHandleForReading.close()
|
|
|
|
// Without suppression this write would raise SIGPIPE and take down the
|
|
// whole swiftpm-testing-helper process instead of throwing.
|
|
#expect(throws: Error.self) {
|
|
try pipe.fileHandleForWriting.write(contentsOf: Data("x".utf8))
|
|
}
|
|
try pipe.fileHandleForWriting.close()
|
|
}
|
|
}
|