Skip to content

Commit 24cd4a2

Browse files
authored
Replace getdtablesize() on Android (#7402)
Works around the existing use of `getdtablesize()` on Android.
1 parent 4e24446 commit 24cd4a2

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Sources/Commands/SwiftRunCommand.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,15 @@ package struct SwiftRunCommand: AsyncSwiftCommand {
297297
var sig_set_all = sigset_t()
298298
sigfillset(&sig_set_all)
299299
sigprocmask(SIG_UNBLOCK, &sig_set_all, nil)
300+
301+
#if os(Android)
302+
let number_fds = Int32(sysconf(_SC_OPEN_MAX))
303+
#else
304+
let number_fds = getdtablesize()
305+
#endif
300306

301307
// 2. close all file descriptors.
302-
for i in 3..<getdtablesize() {
308+
for i in 3..<number_fds {
303309
close(i)
304310
}
305311
#endif

0 commit comments

Comments
 (0)