worker: propagate exit code to main process
authorYuya Nishihara <yuya@tcha.org>
Sat, 15 Apr 2017 13:27:44 +0900
changeset 32042 8f8ad0139b8b
parent 32041 38963a53ab0d
child 32043 b844d0d367e2
worker: propagate exit code to main process Follows up 86cd09bc13ba.
mercurial/worker.py
tests/test-worker.t
--- a/mercurial/worker.py	Sat Apr 15 13:02:34 2017 +0900
+++ b/mercurial/worker.py	Sat Apr 15 13:27:44 2017 +0900
@@ -144,13 +144,15 @@
                 os.close(rfd)
                 for i, item in func(*(staticargs + (pargs,))):
                     os.write(wfd, '%d %s\n' % (i, item))
+                return 0
 
             # make sure we use os._exit in all code paths. otherwise the worker
             # may do some clean-ups which could cause surprises like deadlock.
             # see sshpeer.cleanup for example.
+            ret = 0
             try:
                 try:
-                    scmutil.callcatch(ui, workerfunc)
+                    ret = scmutil.callcatch(ui, workerfunc)
                 finally:
                     ui.flush()
             except KeyboardInterrupt:
@@ -162,7 +164,7 @@
                 finally:
                     os._exit(255)
             else:
-                os._exit(0)
+                os._exit(ret & 255)
         pids.add(pid)
     os.close(wfd)
     fp = os.fdopen(rfd, pycompat.sysstr('rb'), 0)
--- a/tests/test-worker.t	Sat Apr 15 13:02:34 2017 +0900
+++ b/tests/test-worker.t	Sat Apr 15 13:27:44 2017 +0900
@@ -70,8 +70,9 @@
   > test 100000.0 abort
   start
   abort: known exception
-  done
+  [255]
 
   $ hg --config "extensions.t=$abspath" --config 'worker.numcpus=2' \
   > test 100000.0 abort --traceback 2>&1 | grep '^Traceback'
   Traceback (most recent call last):
+  Traceback (most recent call last):