Patchwork D1428: logtoprocess: connect all fds to /dev/null to avoid bad interaction with pager

login
register
mail settings
Submitter phabricator
Date Nov. 17, 2017, 8:25 a.m.
Message ID <e94e76a90190e639b712a12ecdd4b689@localhost.localdomain>
Download mbox | patch
Permalink /patch/25616/
State Not Applicable
Headers show

Comments

phabricator - Nov. 17, 2017, 8:25 a.m.
lothiraldan updated this revision to Diff 3589.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D1428?vs=3530&id=3589

REVISION DETAIL
  https://phab.mercurial-scm.org/D1428

AFFECTED FILES
  hgext/logtoprocess.py
  tests/test-logtoprocess.t

CHANGE DETAILS




To: lothiraldan, #hg-reviewers, yuja
Cc: yuja, mercurial-devel

Patch

diff --git a/tests/test-logtoprocess.t b/tests/test-logtoprocess.t
--- a/tests/test-logtoprocess.t
+++ b/tests/test-logtoprocess.t
@@ -122,4 +122,4 @@ 
   $ touch $TESTTMP/wait-for-touched
   $ sleep 0.2
   $ test -f $TESTTMP/touched && echo "SUCCESS Pager is waiting on ltp" || echo "FAIL Pager is waiting on ltp"
-  FAIL Pager is waiting on ltp
+  SUCCESS Pager is waiting on ltp
diff --git a/hgext/logtoprocess.py b/hgext/logtoprocess.py
--- a/hgext/logtoprocess.py
+++ b/hgext/logtoprocess.py
@@ -79,11 +79,16 @@ 
             else:
                 newsession = {'start_new_session': True}
             try:
-                # connect stdin to devnull to make sure the subprocess can't
-                # muck up that stream for mercurial.
+                # connect std* to devnull to make sure the subprocess can't
+                # muck up these stream for mercurial.
+                # Connect all the streams to be more close to Windows behavior
+                # and pager will wait for scripts to end if we don't do that
+                nullrfd = open(os.devnull, 'r')
+                nullwfd = open(os.devnull, 'w')
                 subprocess.Popen(
-                    script, shell=shell, stdin=open(os.devnull, 'r'), env=env,
-                    close_fds=True, **newsession)
+                    script, shell=shell, stdin=nullrfd,
+                    stdout=nullwfd, stderr=nullwfd,
+                    env=env, close_fds=True, **newsession)
             finally:
                 # mission accomplished, this child needs to exit and not
                 # continue the hg process here.