Skip to content

Commit 5721010

Browse files
authored
Merge pull request #4816 from iCharlesHu/charles/runloop
[5.9] Cherry-pick waitUntilExit: ignore RunLoop.run()'s return value
2 parents c078b15 + 0fe8f34 commit 5721010

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

CoreFoundation/Base.subproj/CFRuntime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ void __CFInitialize(void) {
11791179
if (!__CFInitialized && !__CFInitializing) {
11801180
__CFInitializing = 1;
11811181

1182-
#if __HAS_DISPATCH__
1182+
#if __HAS_DISPATCH__ && !TARGET_OS_MAC
11831183
// libdispatch has to be initialized before CoreFoundation, so to avoid
11841184
// issues with static initializer ordering, we are doing it explicitly.
11851185
libdispatch_init();

Sources/Foundation/Process.swift

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,14 +1134,17 @@ open class Process: NSObject {
11341134
open func waitUntilExit() {
11351135
let runInterval = 0.05
11361136
let currentRunLoop = RunLoop.current
1137-
let checkRunLoop : () -> Bool = (currentRunLoop == self.runLoop)
1138-
? { currentRunLoop.run(mode: .default, before: Date(timeIntervalSinceNow: runInterval)) }
1139-
: { currentRunLoop.run(until: Date(timeIntervalSinceNow: runInterval)); return true }
11401137

1141-
// update .runLoop to allow early wakeup.
1138+
let runRunLoop : () -> Void = (currentRunLoop == self.runLoop)
1139+
? { currentRunLoop.run(mode: .default, before: Date(timeIntervalSinceNow: runInterval)) }
1140+
: { currentRunLoop.run(until: Date(timeIntervalSinceNow: runInterval)) }
1141+
// update .runLoop to allow early wakeup triggered by terminateRunLoop.
11421142
self.runLoop = currentRunLoop
1143-
while self.isRunning && checkRunLoop() {}
1144-
1143+
1144+
while self.isRunning {
1145+
runRunLoop()
1146+
}
1147+
11451148
self.runLoop = nil
11461149
self.runLoopSource = nil
11471150
}

0 commit comments

Comments
 (0)