diff mercurial/posix.py @ 9517:4368f582c806

util.system: Use subprocess instead of os.system subprocess allows the environment and working directory to be specified directly, so the hacks for making temporary changes while forking is no longer necessary. This also fixes failures on solaris where the temporary changes can't be undone because there is no unsetenv.
author Mads Kiilerich <mads@kiilerich.com>
date Sun, 20 Sep 2009 22:19:18 +0200
parents 40196d036a71
children 8b8920209317
line wrap: on
line diff
--- a/mercurial/posix.py	Wed Sep 23 02:31:09 2009 -0500
+++ b/mercurial/posix.py	Sun Sep 20 22:19:18 2009 +0200
@@ -165,17 +165,11 @@
         return inst.errno != errno.ESRCH
 
 def explain_exit(code):
-    """return a 2-tuple (desc, code) describing a process's status"""
-    if os.WIFEXITED(code):
-        val = os.WEXITSTATUS(code)
-        return _("exited with status %d") % val, val
-    elif os.WIFSIGNALED(code):
-        val = os.WTERMSIG(code)
-        return _("killed by signal %d") % val, val
-    elif os.WIFSTOPPED(code):
-        val = os.WSTOPSIG(code)
-        return _("stopped by signal %d") % val, val
-    raise ValueError(_("invalid exit code"))
+    """return a 2-tuple (desc, code) describing a subprocess status
+    (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
 
 def isowner(st):
     """Return True if the stat object st is from the current user."""