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

Implementation of the PEP 433: Easier suppression of file descriptor inheritance #61238

Closed
vstinner opened this issue Jan 25, 2013 · 10 comments
Closed
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement

Comments

@vstinner
Copy link
Member

BPO 17036
Nosy @vstinner
Superseder
  • bpo-18571: Implementation of the PEP 446: non-inheritable file descriptors
  • Files
  • bc88690df059.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2013-08-28.19:56:42.371>
    created_at = <Date 2013-01-25.22:01:25.597>
    labels = ['interpreter-core', 'type-feature']
    title = 'Implementation of the PEP 433: Easier suppression of file descriptor inheritance'
    updated_at = <Date 2013-08-28.19:56:42.370>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2013-08-28.19:56:42.370>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2013-08-28.19:56:42.371>
    closer = 'vstinner'
    components = ['Interpreter Core']
    creation = <Date 2013-01-25.22:01:25.597>
    creator = 'vstinner'
    dependencies = []
    files = ['28887']
    hgrepos = ['173']
    issue_num = 17036
    keywords = ['patch']
    message_count = 10.0
    messages = ['180630', '180636', '180637', '180638', '180903', '180904', '180907', '180908', '180957', '196411']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'Arfrever']
    pr_nums = []
    priority = 'normal'
    resolution = 'rejected'
    stage = None
    status = 'closed'
    superseder = '18571'
    type = 'enhancement'
    url = 'https://bugs.python.org/issue17036'
    versions = ['Python 3.4']

    @vstinner
    Copy link
    Member Author

    I create this issue to review and track the implementation of the PEP-433: "Easier suppression of file descriptor inheritance"
    http://www.python.org/dev/peps/pep-0433/

    @vstinner vstinner added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement labels Jan 25, 2013
    @vstinner
    Copy link
    Member Author

    Here is a patch of the latest revision.

    configure and Python/importlib.h must be regenerated (are not part of the diff).

    @vstinner
    Copy link
    Member Author

    I tested 9bdfa1a3ea8c.patch on Fedora 16 (Linux 3.6, glibc 2.14), Debian Etch (Linux 2.6.19), OpenBSD 5.2, OpenIndiana, FreeBSD 8.2, Windows 7.

    I tested both cases (works/not supported) for O_CLOEXEC and SOCK_CLOEXEC. For the WSA_FLAG_NO_HANDLE_INHERIT flag, I only tested a Windows version not supporting it (Windows 7 SP1 is required).

    @vstinner
    Copy link
    Member Author

    The select module may need more work.

    @vstinner
    Copy link
    Member Author

    New patch:

    • sys.setdefaultcloexec() takes again an argument, so sys.setdefaultcloexec(False) is allowed
    • add cloexec parameter to select.devpoll(), select.kqueue() and select.epoll()
    • when a function accepts a file name and a file descriptor: the cloexec parameter is ignored if the argument is a file descriptor (it was already done for open(), but not for socket.socket on Windows)
    • revert enhancements using cloexec=True to simplify the patch: will be done in another issue
    • fix various bugs in error handling (close newly created file descriptors on error)
    • release the GIL when calling the os: os.urandom(), os.pipe(), os.dup(), etc.

    @vstinner
    Copy link
    Member Author

    My TODO list is almost empty: the implementation is done. I just see possible enhancement on Windows: socket.socket() and os.dup() can use an atomic flag to set close-on-exec if native functions are used (WSASocket, DuplicateHandle) instead of the POSIX API. But it can be done later.

    @vstinner
    Copy link
    Member Author

    "revert enhancements using cloexec=True to simplify the patch: will be done in another issue"

    I just created the issue bpo-17070 to track this task.

    @vstinner
    Copy link
    Member Author

    My TODO list is almost empty

    Oh, I forgot one point: I stil don't know if the close-on-exec flag of
    file descriptors of pass_fds argument of subprocess.Popen should be
    set. If close-on-exec flag is set globally, it's not convinient to
    have to clear the flag manually on each file descriptor.

    @vstinner
    Copy link
    Member Author

    I tested bc88690df059.patch on Solaris 9: test_os failed on openpty(cloexec=True). It looks like setting close-on-exec on master_fd must be done after grantpt().

    @vstinner
    Copy link
    Member Author

    The PEP-433 was rejected, replaced with the PEP-446.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    interpreter-core (Objects, Python, Grammar, and Parser dirs) type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant