Patchwork [5,of,7] procutil: do not convert return code of signal exit to positive number (API)

login
register
mail settings
Submitter Yuya Nishihara
Date April 7, 2018, 1:39 p.m.
Message ID <f7f7e44d201d89712312.1523108381@mimosa>
Download mbox | patch
Permalink /patch/30546/
State Accepted
Headers show

Comments

Yuya Nishihara - April 7, 2018, 1:39 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1523103663 -32400
#      Sat Apr 07 21:21:03 2018 +0900
# Node ID f7f7e44d201d897123122c01b86580c19e46142b
# Parent  91d6e908f4703e421c887f24ae8c23bf98c32202
procutil: do not convert return code of signal exit to positive number (API)

The docstring states that "codes from kill are negative", and it doesn't
make sense to make exit/signal code ambiguous.

.. api::

   ``hook.hook()`` and ``hook.runhooks()`` may return a negative integer
   to denote that the process was killed by signal.

Patch

diff --git a/mercurial/utils/procutil.py b/mercurial/utils/procutil.py
--- a/mercurial/utils/procutil.py
+++ b/mercurial/utils/procutil.py
@@ -83,7 +83,7 @@  def explainexit(code):
     (codes from kill are negative - not os.system/wait encoding)"""
     if code >= 0:
         return _("exited with status %d") % code, code
-    return _("killed by signal %d") % -code, -code
+    return _("killed by signal %d") % -code, code
 
 class _pfile(object):
     """File-like wrapper for a stream opened by subprocess.Popen()"""