Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace getdtablesize() on Android #7402

Merged
merged 1 commit into from Mar 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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