diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -5,7 +5,7 @@
 # This software may be used and distributed according to the terms of the
 # GNU General Public License version 2 or any later version.
 
-import errno, os, re, xml.dom.minidom, shutil, posixpath
+import errno, os, re, xml.dom.minidom, shutil, posixpath, sys
 import stat, subprocess, tarfile
 from i18n import _
 import config, scmutil, util, node, error, cmdutil, bookmarks, match as matchmod
@@ -693,6 +693,10 @@
             # --non-interactive.
             if commands[0] in ('update', 'checkout', 'commit'):
                 cmd.append('--non-interactive')
+        # GUI programs on windows (pythonw) has no valid stdin for
+        # subprocess.Popen.
+        if os.name == 'nt' and not util.isatty(sys.stdin):
+            extrakw['stdin'] = subprocess.PIPE
         cmd.extend(commands)
         if filename is not None:
             path = os.path.join(self._ctx._repo.origroot, self._path, filename)
@@ -950,9 +954,19 @@
         errpipe = None
         if self._ui.quiet:
             errpipe = open(os.devnull, 'w')
+        inpipe = None
+        # GUI programs on windows (pythonw) has no valid stdin or
+        # stderr for subprocess.Popen.
+        if os.name == 'nt':
+            if not util.isatty(sys.stdin):
+                inpipe = subprocess.PIPE
+            if errpipe is None and not util.isatty(sys.stderr):
+                errpipe = subprocess.PIPE
+
         p = subprocess.Popen([self._gitexecutable] + commands, bufsize=-1,
                              cwd=cwd, env=env, close_fds=util.closefds,
-                             stdout=subprocess.PIPE, stderr=errpipe)
+                             stdout=subprocess.PIPE, stderr=errpipe,
+                             stdin=inpipe)
         if stream:
             return p.stdout, None
 
