[issue40299] os.dup seems broken with execvp (LINUX)

2020-04-16 Thread krsna
krsna added the comment: Closing has behavior is documented "The file descriptor created by "os.dup" is not inherited by child processes by default since Python 3.4. https://docs.python.org/3/library/os.html#os.dup; -- resolution: -> not a bug stage: -> resolved status: open ->

[issue40299] os.dup seems broken with execvp (LINUX)

2020-04-16 Thread krsna
krsna added the comment: I should read the updated documentation changes to modules more often. Adding the inheritable works and yes I tested with `os.dup2` which seemed consistent with C's dups2. I still think it is quite odd that the low level `dup` function has a different behavior than

[issue40299] os.dup seems broken with execvp (LINUX)

2020-04-16 Thread Martin Panter
Martin Panter added the comment: The file descriptor created by "os.dup" is not inherited by child processes by default since Python 3.4. https://docs.python.org/3/library/os.html#os.dup Does it work if you use "os.set_inheritable" or "os.dup2" (which apparently sets it inhertiable by

[issue40299] os.dup seems broken with execvp (LINUX)

2020-04-16 Thread krsna
New submission from krsna : ---CODE--- import os path = "file.txt" fd = os.open(path, os.O_WRONLY) os.close(1) #STDOUT os.dup(fd) pid = os.fork() if pid == 0: args = "ls -l".split() os.execvp(args[0], args) else: os.waitpid(pid, 0) print('Done from Parent') --- END CODE