File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -1025,7 +1025,7 @@ final class IntegrationTests: XCTestCase {
1025
1025
// Foundation.Process on Linux doesn't correctly detect when child process dies (creating zombie processes)
1026
1026
func testCanDealWithRunawayChildProcesses( ) async throws {
1027
1027
self . logger = Logger ( label: " x " )
1028
- self . logger. logLevel = . trace
1028
+ self . logger. logLevel = . info
1029
1029
let p = ProcessExecutor (
1030
1030
executable: " /bin/bash " ,
1031
1031
[
@@ -1070,10 +1070,19 @@ final class IntegrationTests: XCTestCase {
1070
1070
try await group. waitForAll ( )
1071
1071
1072
1072
// Let's check that the subprocess (/usr/bin/yes) of our subprocess (/bin/bash) is actually dead
1073
- let killRet = kill ( pid, 0 )
1074
- let errnoCode = errno
1075
- XCTAssertEqual ( - 1 , killRet)
1076
- XCTAssertEqual ( ESRCH, errnoCode)
1073
+ // This is a tiny bit racy because the pid isn't immediately invalidated, so let's allow a few failures
1074
+ for attempt in 0 ..< . max {
1075
+ let killRet = kill ( pid, 0 )
1076
+ let errnoCode = errno
1077
+ guard killRet == - 1 || attempt > 5 else {
1078
+ logger. error ( " kill didn't fail on attempt \( attempt) , trying again... " )
1079
+ usleep ( 100_000 )
1080
+ continue
1081
+ }
1082
+ XCTAssertEqual ( - 1 , killRet)
1083
+ XCTAssertEqual ( ESRCH, errnoCode)
1084
+ break
1085
+ }
1077
1086
}
1078
1087
}
1079
1088
#endif
You can’t perform that action at this time.
0 commit comments