Skip to content

Commit 7aba3c2

Browse files
committed
Merge pull request #2162 from modocache/remove-unused-subprocess
2 parents 7aa3b89 + 005d01b commit 7aba3c2

File tree

1 file changed

+0
-43
lines changed

1 file changed

+0
-43
lines changed

stdlib/private/SwiftPrivateLibcExtras/Subprocess.swift

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -234,29 +234,6 @@ internal func _make_posix_spawn_file_actions_t()
234234
#endif
235235
#endif
236236

237-
internal func _readAll(_ fd: CInt) -> String {
238-
var buffer = [UInt8](repeating: 0, count: 1024)
239-
var usedBytes = 0
240-
while true {
241-
let readResult: ssize_t = buffer.withUnsafeMutableBufferPointer {
242-
(buffer) in
243-
let ptr = UnsafeMutablePointer<Void>(buffer.baseAddress! + usedBytes)
244-
return read(fd, ptr, size_t(buffer.count - usedBytes))
245-
}
246-
if readResult > 0 {
247-
usedBytes += readResult
248-
continue
249-
}
250-
if readResult == 0 {
251-
break
252-
}
253-
preconditionFailure("read() failed")
254-
}
255-
return String._fromCodeUnitSequenceWithRepair(
256-
UTF8.self, input: buffer[0..<usedBytes]).0
257-
}
258-
259-
260237
internal func _signalToString(_ signal: Int) -> String {
261238
switch CInt(signal) {
262239
case SIGILL: return "SIGILL"
@@ -298,26 +275,6 @@ public func posixWaitpid(_ pid: pid_t) -> ProcessTerminationStatus {
298275
preconditionFailure("did not understand what happened to child process")
299276
}
300277

301-
public func runChild(_ args: [String])
302-
-> (stdout: String, stderr: String, status: ProcessTerminationStatus) {
303-
let (pid, _, stdoutFD, stderrFD) = spawnChild(args)
304-
305-
// FIXME: reading stdout and stderr sequentially can block. Should use
306-
// select(). This is not so simple to implement because of:
307-
// <rdar://problem/17828358> Darwin module is missing fd_set-related macros
308-
let stdout = _readAll(stdoutFD)
309-
let stderr = _readAll(stderrFD)
310-
311-
if close(stdoutFD) != 0 {
312-
preconditionFailure("close() failed")
313-
}
314-
if close(stderrFD) != 0 {
315-
preconditionFailure("close() failed")
316-
}
317-
let status = posixWaitpid(pid)
318-
return (stdout, stderr, status)
319-
}
320-
321278
#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
322279
@_silgen_name("_NSGetEnviron")
323280
func _NSGetEnviron() -> UnsafeMutablePointer<UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>>

0 commit comments

Comments
 (0)