File tree Expand file tree Collapse file tree 4 files changed +38
-4
lines changed Expand file tree Collapse file tree 4 files changed +38
-4
lines changed Original file line number Diff line number Diff line change @@ -103,6 +103,10 @@ public struct Configuration: Sendable {
103
103
var _spawnResult = spawnResultBox!. take ( ) !
104
104
105
105
let execution = _spawnResult. execution
106
+ defer {
107
+ // Close process file descriptor now we finished monitoring
108
+ execution. processIdentifier. close ( )
109
+ }
106
110
107
111
return try await withAsyncTaskCleanupHandler {
108
112
let inputIO = _spawnResult. inputWriteEnd ( )
@@ -127,9 +131,6 @@ public struct Configuration: Sendable {
127
131
for: execution. processIdentifier
128
132
)
129
133
130
- // Close process file descriptor now we finished monitoring
131
- execution. processIdentifier. close ( )
132
-
133
134
return ExecutionResult (
134
135
terminationStatus: terminationStatus,
135
136
value: try result. get ( )
Original file line number Diff line number Diff line change @@ -288,7 +288,7 @@ final class AsyncIO: Sendable {
288
288
)
289
289
if rc != 0 {
290
290
_registration. withLock { storage in
291
- storage. removeValue ( forKey: fileDescriptor. rawValue)
291
+ _ = storage. removeValue ( forKey: fileDescriptor. rawValue)
292
292
}
293
293
294
294
let capturedError = errno
Original file line number Diff line number Diff line change @@ -179,6 +179,17 @@ extension InputProtocol where Self == FileDescriptorInput {
179
179
closeAfterSpawningProcess: closeAfterSpawningProcess
180
180
)
181
181
}
182
+
183
+ /// Create a Subprocess input that reads from the standard input of
184
+ /// current process.
185
+ ///
186
+ /// The file descriptor isn't closed afterwards.
187
+ public static var standardInput : Self {
188
+ return Self . fileDescriptor (
189
+ . standardInput,
190
+ closeAfterSpawningProcess: false
191
+ )
192
+ }
182
193
}
183
194
184
195
extension InputProtocol {
Original file line number Diff line number Diff line change @@ -231,6 +231,28 @@ extension OutputProtocol where Self == FileDescriptorOutput {
231
231
) -> Self {
232
232
return . init( fileDescriptor: fd, closeAfterSpawningProcess: closeAfterSpawningProcess)
233
233
}
234
+
235
+ /// Create a Subprocess output that writes output to the standard output of
236
+ /// current process.
237
+ ///
238
+ /// The file descriptor isn't closed afterwards.
239
+ public static var standardOutput : Self {
240
+ return Self . fileDescriptor (
241
+ . standardOutput,
242
+ closeAfterSpawningProcess: false
243
+ )
244
+ }
245
+
246
+ /// Create a Subprocess output that write output to the standard error of
247
+ /// current process.
248
+ ///
249
+ /// The file descriptor isn't closed afterwards.
250
+ public static var standardError : Self {
251
+ return Self . fileDescriptor (
252
+ . standardError,
253
+ closeAfterSpawningProcess: false
254
+ )
255
+ }
234
256
}
235
257
236
258
extension OutputProtocol where Self == StringOutput < UTF8 > {
You can’t perform that action at this time.
0 commit comments