File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -64,7 +64,7 @@ func posixPipe() -> (readFD: CInt, writeFD: CInt) {
64
64
/// stderr.
65
65
public func spawnChild( args: [ String ] )
66
66
-> ( pid: pid_t , stdinFD: CInt , stdoutFD: CInt , stderrFD: CInt ) {
67
- var fileActions : posix_spawn_file_actions_t = nil
67
+ var fileActions : posix_spawn_file_actions_t = _make_posix_spawn_file_actions_t ( )
68
68
if swift_posix_spawn_file_actions_init ( & fileActions) != 0 {
69
69
preconditionFailure ( " swift_posix_spawn_file_actions_init() failed " )
70
70
}
@@ -140,6 +140,14 @@ public func spawnChild(args: [String])
140
140
return ( pid, childStdin. writeFD, childStdout. readFD, childStderr. readFD)
141
141
}
142
142
143
+ internal func _make_posix_spawn_file_actions_t( ) -> posix_spawn_file_actions_t {
144
+ #if os(Linux) || os(FreeBSD)
145
+ return posix_spawn_file_actions_t ( )
146
+ #else
147
+ return nil
148
+ #endif
149
+ }
150
+
143
151
internal func _readAll( fd: CInt ) -> String {
144
152
var buffer = [ UInt8] ( repeating: 0 , count: 1024 )
145
153
var usedBytes = 0
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ public func _stdlib_pthread_create_block<Argument, Result>(
71
71
let contextAsOpaque = OpaquePointer ( bitPattern: Unmanaged . passRetained ( context) )
72
72
let contextAsVoidPointer = UnsafeMutablePointer < Void > ( contextAsOpaque)
73
73
74
- var threadID : pthread_t = nil
74
+ var threadID : pthread_t = _make_pthread_t ( )
75
75
let result = pthread_create ( & threadID, attr,
76
76
invokeBlockContext, contextAsVoidPointer)
77
77
if result == 0 {
@@ -81,6 +81,14 @@ public func _stdlib_pthread_create_block<Argument, Result>(
81
81
}
82
82
}
83
83
84
+ internal func _make_pthread_t( ) -> pthread_t {
85
+ #if os(Linux) || os(FreeBSD)
86
+ return pthread_t ( )
87
+ #else
88
+ return nil
89
+ #endif
90
+ }
91
+
84
92
/// Block-based wrapper for `pthread_join`.
85
93
public func _stdlib_pthread_join< Result> (
86
94
thread: pthread_t ,
You can’t perform that action at this time.
0 commit comments