Mercurial > hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
9516:f8048c334066 | 9517:4368f582c806 |
---|---|
163 return True | 163 return True |
164 except OSError, inst: | 164 except OSError, inst: |
165 return inst.errno != errno.ESRCH | 165 return inst.errno != errno.ESRCH |
166 | 166 |
167 def explain_exit(code): | 167 def explain_exit(code): |
168 """return a 2-tuple (desc, code) describing a process's status""" | 168 """return a 2-tuple (desc, code) describing a subprocess status |
169 if os.WIFEXITED(code): | 169 (codes from kill are negative - not os.system/wait encoding)""" |
170 val = os.WEXITSTATUS(code) | 170 if code >= 0: |
171 return _("exited with status %d") % val, val | 171 return _("exited with status %d") % code, code |
172 elif os.WIFSIGNALED(code): | 172 return _("killed by signal %d") % -code, -code |
173 val = os.WTERMSIG(code) | |
174 return _("killed by signal %d") % val, val | |
175 elif os.WIFSTOPPED(code): | |
176 val = os.WSTOPSIG(code) | |
177 return _("stopped by signal %d") % val, val | |
178 raise ValueError(_("invalid exit code")) | |
179 | 173 |
180 def isowner(st): | 174 def isowner(st): |
181 """Return True if the stat object st is from the current user.""" | 175 """Return True if the stat object st is from the current user.""" |
182 return st.st_uid == os.getuid() | 176 return st.st_uid == os.getuid() |
183 | 177 |