Applied patch 1669481, slightly modified: Support close_fds on Win32
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index 745c483..ca9489e 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -545,9 +545,10 @@
             if preexec_fn is not None:
                 raise ValueError("preexec_fn is not supported on Windows "
                                  "platforms")
-            if close_fds:
+            if close_fds and (stdin is not None or stdout is not None or
+                              stderr is not None):
                 raise ValueError("close_fds is not supported on Windows "
-                                 "platforms")
+                                 "platforms if you redirect stdin/stdout/stderr")
         else:
             # POSIX
             if startupinfo is not None:
@@ -804,9 +805,7 @@
                 hp, ht, pid, tid = CreateProcess(executable, args,
                                          # no special security
                                          None, None,
-                                         # must inherit handles to pass std
-                                         # handles
-                                         1,
+                                         int(not close_fds),
                                          creationflags,
                                          env,
                                          cwd,
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index c2db6fa..e79159c 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -617,8 +617,16 @@
             self.assertRaises(ValueError, subprocess.call,
                               [sys.executable,
                                "-c", "import sys; sys.exit(47)"],
+                              stdout=subprocess.PIPE,
                               close_fds=True)
 
+        def test_close_fds(self):
+            # close file descriptors
+            rc = subprocess.call([sys.executable, "-c",
+                                  "import sys; sys.exit(47)"],
+                                  close_fds=True)
+            self.assertEqual(rc, 47)
+
         def test_shell_sequence(self):
             # Run command through the shell (sequence)
             newenv = os.environ.copy()