Skip to content

Commit 0faf723

Browse files
committed
Disable testWriteToClosedPipe() and testReadFromClosedPipe() because we can't safely write to / read from a closed fd
1 parent 58445d9 commit 0faf723

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

Sources/Subprocess/Platforms/Subprocess+Linux.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,9 @@ private func monitorThreadFunc(context: MonitorThreadContext) {
225225
repeating: epoll_event(events: 0, data: epoll_data(fd: 0)),
226226
count: 256
227227
)
228-
var waitMask = sigset_t();
229-
sigemptyset(&waitMask);
230-
sigaddset(&waitMask, SIGCHLD);
228+
var waitMask = sigset_t()
229+
sigemptyset(&waitMask)
230+
sigaddset(&waitMask, SIGCHLD)
231231
// Enter the monitor loop
232232
monitorLoop: while true {
233233
let eventCount = epoll_pwait(

Sources/Subprocess/Thread.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private final class WorkQueue: Sendable {
106106
#if canImport(WinSDK)
107107
EnterCriticalSection(self.mutex)
108108
defer {
109-
LeaveCriticalSection(self.mutex);
109+
LeaveCriticalSection(self.mutex)
110110
}
111111
#else
112112
pthread_mutex_lock(self.mutex)
@@ -140,7 +140,7 @@ private final class WorkQueue: Sendable {
140140
self.withLock { queue in
141141
queue.append(workItem)
142142
#if canImport(WinSDK)
143-
WakeConditionVariable(self.waitCondition);
143+
WakeConditionVariable(self.waitCondition)
144144
#else
145145
pthread_cond_signal(self.waitCondition)
146146
#endif
@@ -151,7 +151,7 @@ private final class WorkQueue: Sendable {
151151
self.withLock { queue in
152152
queue.removeAll()
153153
#if canImport(WinSDK)
154-
WakeConditionVariable(self.waitCondition);
154+
WakeConditionVariable(self.waitCondition)
155155
#else
156156
pthread_cond_signal(self.waitCondition)
157157
#endif
@@ -209,8 +209,8 @@ private func _shutdownWorkerThread() {
209209
}
210210
_workQueue.shutdown()
211211
#if canImport(WinSDK)
212-
WaitForSingleObject(thread, INFINITE);
213-
CloseHandle(thread);
212+
WaitForSingleObject(thread, INFINITE)
213+
CloseHandle(thread)
214214
DeleteCriticalSection(_workQueue.mutex)
215215
// We do not need to destroy CONDITION_VARIABLE
216216
#else
@@ -225,7 +225,7 @@ private func _shutdownWorkerThread() {
225225
// MARK: - AtomicCounter
226226

227227
#if canImport(Darwin)
228-
// Unfortunately on Darwin we can unconditionally use Atomic since it requires macOS 15
228+
// Unfortunately on Darwin we cannot unconditionally use Atomic since it requires macOS 15
229229
internal struct AtomicCounter: ~Copyable {
230230
private let storage: OSAllocatedUnfairLock<UInt8>
231231

Tests/SubprocessTests/AsyncIOTests.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ extension SubprocessAsyncIOTests {
135135

136136
// MARK: - Error Handling Tests
137137
extension SubprocessAsyncIOTests {
138-
@Test func testWriteToClosedPipe() async throws {
138+
@Test(.disabled("Cannot safely write to a closed fd without risking it being reused"))
139+
func testWriteToClosedPipe() async throws {
139140
var pipe = try CreatedPipe(closeWhenDone: true, purpose: .input)
140141
var writeChannel = try _require(pipe.writeFileDescriptor()).createIOChannel()
141142
var readChannel = try _require(pipe.readFileDescriptor()).createIOChannel()
@@ -171,7 +172,8 @@ extension SubprocessAsyncIOTests {
171172

172173
}
173174

174-
@Test func testReadFromClosedPipe() async throws {
175+
@Test(.disabled("Cannot safely read from a closed fd without risking it being reused"))
176+
func testReadFromClosedPipe() async throws {
175177
var pipe = try CreatedPipe(closeWhenDone: true, purpose: .input)
176178
var writeChannel = try _require(pipe.writeFileDescriptor()).createIOChannel()
177179
var readChannel = try _require(pipe.readFileDescriptor()).createIOChannel()

0 commit comments

Comments
 (0)