I have a script, which works reasonably well under Python-2. It uses os.pipe() to create a pipe, and then passes the descriptor of the writing side of the pipe to a child process:
reader, writer = os.pipe()
pid = os.fork()
if pid == 0:
# Child
os.close(reader)
os.execvp('command', ['command', '-o', '/dev/fd/%d' % writer])
...
Under Python-2 the above works, and the child writes to the specified file-descriptor -- allowing the parent to read it.
Under Python-3 the child complains about being unable to open the /dev/fd/4 -- which means, the descriptor is not passed to the child for some reason. What would that reason be -- and is it possible to invoke os.execvp with the old, expected, behavior?