[New-bugs-announce] [issue32862] os.dup2(fd, fd, inheritable=False) behaves inconsistently

Alexey Izbyshev report at bugs.python.org
Fri Feb 16 22:24:02 EST 2018


New submission from Alexey Izbyshev <izbyshev at ispras.ru>:

os.dup2(fd, fd, inheritable=False) may fail or change fd inheritability in following ways:

1) POSIX without F_DUP2FD_CLOEXEC
1.1) dup3() is available (a common case for Linux): OSError (EINVAL, dup3() doesn't allow equal descriptors)
1.2) dup3() is not available: fd made non-inheritable

2) POSIX with F_DUP2FD_CLOEXEC (FreeBSD): inheritability is not changed

3) Windows: fd made non-inheritable

In contrast, os.dup2(fd, fd, inheritable=True) never changes fd inheritability (same as before PEP 446 landed). I suggest to make os.dup2(fd, fd, inheritable=False) behave the same.

----------
components: Extension Modules, Library (Lib)
messages: 312266
nosy: benjamin.peterson, izbyshev, vstinner
priority: normal
severity: normal
status: open
title: os.dup2(fd, fd, inheritable=False) behaves inconsistently
type: behavior
versions: Python 3.6, Python 3.7

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue32862>
_______________________________________


More information about the New-bugs-announce mailing list