GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — bpo-38061: os.closerange() uses closefrom() on FreeBSD by vstinner · Pull Request #19696 · python/cpython

bpo-38061: os.closerange() uses closefrom() on FreeBSD #19696

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.

Sign up for GitHub

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

Merged
vstinner merged 1 commit into python:master from vstinner:os_closerange
Apr 24, 2020

Uh oh!

There was an error while loading. Please reload this page.

Merged

bpo-38061: os.closerange() uses closefrom() on FreeBSD #19696

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
1 commit
Select commit
0781dad
bpo-38061: os.closerange() uses closefrom() on FreeBSD
vstinner Apr 23, 2020
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

6 changes: 6 additions & 0 deletions 6 Misc/NEWS.d/next/Library/2020-04-24-01-27-08.bpo-38061.cdlkMz.rst
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
On FreeBSD, ``os.closerange(fd_low, fd_high)`` now calls ``closefrom(fd_low)``
if *fd_high* is greater than or equal to ``sysconf(_SC_OPEN_MAX)``.

Initial patch by Ed Maste (emaste), Conrad Meyer (cem), Kyle Evans (kevans)
and Kubilay Kocak (koobs):
Comment thread

@koobs koobs Apr 24, 2020

Copy link
Copy Markdown

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can remove this, full credit to Ed, Conrad & Kyle

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@vstinner vstinner Apr 24, 2020

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if you didn't write the patch itself, you helped to get it in FreeBSD package, and so you deserve to be credited for this work ;-) Thanks @koobs!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=242274
27 changes: 20 additions & 7 deletions 27 Modules/posixmodule.c
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -8687,10 +8687,13 @@ _fdwalk_close_func(void *lohi, int fd)
int lo = ((int *)lohi)[0];
int hi = ((int *)lohi)[1];

if (fd >= hi)
if (fd >= hi) {
return 1;
else if (fd >= lo)
close(fd);
}
else if (fd >= lo) {
/* Ignore errors */
(void)close(fd);
}
return 0;
}
#endif /* HAVE_FDWALK */
Expand All @@ -8711,8 +8714,6 @@ os_closerange_impl(PyObject *module, int fd_low, int fd_high)
{
#ifdef HAVE_FDWALK
int lohi[2];
#else
int i;
#endif
Py_BEGIN_ALLOW_THREADS
_Py_BEGIN_SUPPRESS_IPH
Expand All @@ -8721,8 +8722,20 @@ os_closerange_impl(PyObject *module, int fd_low, int fd_high)
lohi[1] = fd_high;
fdwalk(_fdwalk_close_func, lohi);
#else
for (i = Py_MAX(fd_low, 0); i < fd_high; i++)
close(i);
fd_low = Py_MAX(fd_low, 0);
#ifdef __FreeBSD__
if (fd_high >= sysconf(_SC_OPEN_MAX)) {
/* Any errors encountered while closing file descriptors are ignored */
closefrom(fd_low);
}
else
#endif
{
for (int i = fd_low; i < fd_high; i++) {
/* Ignore errors */
(void)close(i);
}
}
#endif
_Py_END_SUPPRESS_IPH
Py_END_ALLOW_THREADS
Expand Down
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.