Skip to content

PEP446 (CLOEXEC by default) violation with fcntl.fcntl(..., fcntl.F_DUPFD) #71337

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

Closed
socketpair mannequin opened this issue May 29, 2016 · 5 comments
Closed

PEP446 (CLOEXEC by default) violation with fcntl.fcntl(..., fcntl.F_DUPFD) #71337

socketpair mannequin opened this issue May 29, 2016 · 5 comments
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@socketpair
Copy link
Mannequin

socketpair mannequin commented May 29, 2016

BPO 27150
Nosy @vstinner, @socketpair, @vadmium

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 = None
created_at = <Date 2016-05-29.07:34:25.758>
labels = ['type-bug', 'library', 'docs']
title = 'PEP446 (CLOEXEC by default) violation with fcntl.fcntl(..., fcntl.F_DUPFD)'
updated_at = <Date 2016-05-29.18:26:37.748>
user = 'https://github.com/socketpair'

bugs.python.org fields:

activity = <Date 2016-05-29.18:26:37.748>
actor = 'socketpair'
assignee = 'docs@python'
closed = False
closed_date = None
closer = None
components = ['Documentation', 'Library (Lib)']
creation = <Date 2016-05-29.07:34:25.758>
creator = 'socketpair'
dependencies = []
files = []
hgrepos = []
issue_num = 27150
keywords = []
message_count = 4.0
messages = ['266591', '266592', '266595', '266610']
nosy_count = 4.0
nosy_names = ['vstinner', 'docs@python', 'socketpair', 'martin.panter']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue27150'
versions = ['Python 3.4', 'Python 3.5', 'Python 3.6']

@socketpair
Copy link
Mannequin Author

socketpair mannequin commented May 29, 2016

  1. Need fix the code
  2. Fix documentation
  3. Update PEP-446 description.

There is F_DUPFD_CLOEXEC constant, that must be used instead of F_DUPFD transparently when kernel >= 2.6.24.

@socketpair socketpair mannequin added docs Documentation in the Doc dir stdlib Python modules in the Lib dir labels May 29, 2016
@socketpair socketpair mannequin assigned docspython May 29, 2016
@socketpair socketpair mannequin added the type-bug An unexpected behavior, bug, or error label May 29, 2016
@vadmium
Copy link
Member

vadmium commented May 29, 2016

I don’t see any violation or anything needing fixing in the documentation or code. Can you elaborate?

The fcntl() documentation says “The values used for ‘cmd’ [F_DUPFD, etc] are operating system dependent, and are available as constants in the ‘fcntl’ module, using the same names as used in the relevant C header files.” The newest version of Posix specifies both the F_DUPFD and F_DUPFD_CLOEXEC. It would be misleading for Python to use one when the user specified the other.

If you want a best-effort version of F_DUPFD_CLOEXEC for a single-threaded program, why not use os.dup()? I presume this uses F_DUPFD_CLOEXEC where appropriate, and uses some non-atomic fallback if necessary.

@vstinner
Copy link
Member

I don't think that it's possible nor worth it to wrap all fcntl() and all
ioctl() calls. I see these functions as very low-level APIs and so I
consider that the caller is responsible of what he/she does.

If you want to change something, explian in fcntl module doc that the PEP-466 is not implemented in this module znd it's a deliberate choice.

I agree with Martin, it's the responsability of the dev to use the right
command depending on the use case.

@socketpair
Copy link
Mannequin Author

socketpair mannequin commented May 29, 2016

OK, it will be consistent, if docs mention that F_DUPFD will not set O_CLOEXEC automatically, mentiont that F_DUPFD_CLOEXEC should be used for that, and also mention PEP-446 somewhere.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
@serhiy-storchaka
Copy link
Member

F_DUPFD is not explicitly documented, so I do not think that we should do anything here.

@serhiy-storchaka serhiy-storchaka closed this as not planned Won't fix, can't repro, duplicate, stale Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

3 participants