diff -r e0866c047e64 -r ac9de799d390 mercurial/commandserver.py --- a/mercurial/commandserver.py Wed Dec 02 14:27:45 2020 +0530 +++ b/mercurial/commandserver.py Thu Dec 03 17:18:49 2020 +0530 @@ -355,7 +355,18 @@ ) try: - ret = self._dispatchcommand(req) & 255 + err = None + try: + status = self._dispatchcommand(req) + except error.StdioError as e: + status = -1 + err = e + + retval = dispatch.closestdio(req.ui, err) + if retval: + status = retval + + ret = status & 255 # If shutdown-on-interrupt is off, it's important to write the # result code *after* SIGINT handler removed. If the result code # were lost, the client wouldn't be able to continue processing.