@@ -167,29 +167,6 @@ internal func _make_posix_spawn_file_actions_t()
167
167
}
168
168
#endif
169
169
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
-
193
170
internal func _signalToString( _ signal: Int ) -> String {
194
171
switch CInt ( signal) {
195
172
case SIGILL: return " SIGILL "
@@ -231,26 +208,6 @@ public func posixWaitpid(_ pid: pid_t) -> ProcessTerminationStatus {
231
208
preconditionFailure ( " did not understand what happened to child process " )
232
209
}
233
210
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
-
254
211
#if os(OSX) || os(iOS) || os(watchOS) || os(tvOS)
255
212
@_silgen_name ( " _NSGetEnviron " )
256
213
func _NSGetEnviron( ) -> UnsafeMutablePointer < UnsafeMutablePointer < UnsafeMutablePointer < CChar > ? > >
0 commit comments