# HG changeset patch # User Yuya Nishihara # Date 2017-04-15 04:27:44 # Node ID 8f8ad0139b8b048a51d395754c233b93d6fba6e3 # Parent 38963a53ab0dba29711b5a4d6f21147064d05259 worker: propagate exit code to main process Follows up 86cd09bc13ba. diff --git a/mercurial/worker.py b/mercurial/worker.py --- a/mercurial/worker.py +++ b/mercurial/worker.py @@ -144,13 +144,15 @@ def _posixworker(ui, func, staticargs, a 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 @@ def _posixworker(ui, func, staticargs, a 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) diff --git a/tests/test-worker.t b/tests/test-worker.t --- a/tests/test-worker.t +++ b/tests/test-worker.t @@ -70,8 +70,9 @@ Known exception should be caught, but pr > 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):