Skip to content

Commit

Permalink
Replace getdtablesize() on Android (#7402)
Browse files Browse the repository at this point in the history
Works around the existing use of `getdtablesize()` on Android.
  • Loading branch information
finagolfin committed Mar 13, 2024
1 parent 4e24446 commit 24cd4a2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Sources/Commands/SwiftRunCommand.swift
Expand Up @@ -297,9 +297,15 @@ package struct SwiftRunCommand: AsyncSwiftCommand {
var sig_set_all = sigset_t()
sigfillset(&sig_set_all)
sigprocmask(SIG_UNBLOCK, &sig_set_all, nil)

#if os(Android)
let number_fds = Int32(sysconf(_SC_OPEN_MAX))
#else
let number_fds = getdtablesize()
#endif

// 2. close all file descriptors.
for i in 3..<getdtablesize() {
for i in 3..<number_fds {
close(i)
}
#endif
Expand Down

0 comments on commit 24cd4a2

Please sign in to comment.