worker: propagate exit code to main process
Follows up
86cd09bc13ba.
--- 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):