I had a problem: using Python 2.7, it was not possible to create a subprocess using
subprocess.Popen([.......], close_fds=True, stdout=subprocess.PIPE, ...)
On windows, because of limitations. The use of close_fds
was needed in my case, as I did not wanted the subprocess to inherit from already opened files file-descriptor.
This is a known bug, which was fixed on Python 3.4+
The question I had was: How do I use subprocess without getting
close_fds is not supported on Windows platforms if you redirect stdin/stdout/stderr
Answer below
This is definatly a tricky hack: answer is to iterate through already opened file descriptors, just before using the
subprocess
module.Here is a sample that would crash without it:
Now with the fix:
Works.
Hope i helped