Skip to content

Commit 005d01b

Browse files
committed
[PrivateLibcExtras] Remove unused methods
Remove `runChild()`, which is no longer used anywhere in the codebase. Also remove `_readAll()`, which was only used within `runChild()`.
1 parent 91f0284 commit 005d01b

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
@@ -167,29 +167,6 @@ internal func _make_posix_spawn_file_actions_t()
167167
}
168168
#endif
169169

170-
internal func _readAll(_ fd: CInt) -> String {
171-
var buffer = [UInt8](repeating: 0, count: 1024)
172-
var usedBytes = 0
173-
while true {
174-
let readResult: ssize_t = buffer.withUnsafeMutableBufferPointer {
175-
(buffer) in
176-
let ptr = UnsafeMutablePointer<Void>(buffer.baseAddress! + usedBytes)
177-
return read(fd, ptr, size_t(buffer.count - usedBytes))
178-
}
179-
if readResult > 0 {
180-
usedBytes += readResult
181-
continue
182-
}
183-
if readResult == 0 {
184-
break
185-
}
186-
preconditionFailure("read() failed")
187-
}
188-
return String._fromCodeUnitSequenceWithRepair(
189-
UTF8.self, input: buffer[0..<usedBytes]).0
190-
}
191-
192-
193170
internal func _signalToString(_ signal: Int) -> String {
194171
switch CInt(signal) {
195172
case SIGILL: return "SIGILL"
@@ -231,26 +208,6 @@ public func posixWaitpid(_ pid: pid_t) -> ProcessTerminationStatus {
231208
preconditionFailure("did not understand what happened to child process")
232209
}
233210

234-
public func runChild(_ args: [String])
235-
-> (stdout: String, stderr: String, status: ProcessTerminationStatus) {
236-
let (pid, _, stdoutFD, stderrFD) = spawnChild(args)
237-
238-
// FIXME: reading stdout and stderr sequentially can block. Should use
239-
// select(). This is not so simple to implement because of:
240-
// <rdar://problem/17828358> Darwin module is missing fd_set-related macros
241-
let stdout = _readAll(stdoutFD)
242-
let stderr = _readAll(stderrFD)
243-
244-
if close(stdoutFD) != 0 {
245-
preconditionFailure("close() failed")
246-
}
247-
if close(stderrFD) != 0 {
248-
preconditionFailure("close() failed")
249-
}
250-
let status = posixWaitpid(pid)
251-
return (stdout, stderr, status)
252-
}
253-
254211
#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
255212
@_silgen_name("_NSGetEnviron")
256213
func _NSGetEnviron() -> UnsafeMutablePointer<UnsafeMutablePointer<UnsafeMutablePointer<CChar>?>>

0 commit comments

Comments
 (0)