equal
deleted
inserted
replaced
578 if pos in after: |
578 if pos in after: |
579 postout += after.pop(pos) |
579 postout += after.pop(pos) |
580 |
580 |
581 return exitcode, postout |
581 return exitcode, postout |
582 |
582 |
|
583 wifexited = getattr(os, "WIFEXITED", lambda x: False) |
583 def run(cmd, options, replacements): |
584 def run(cmd, options, replacements): |
584 """Run command in a sub-process, capturing the output (stdout and stderr). |
585 """Run command in a sub-process, capturing the output (stdout and stderr). |
585 Return a tuple (exitcode, output). output is None in debug mode.""" |
586 Return a tuple (exitcode, output). output is None in debug mode.""" |
586 # TODO: Use subprocess.Popen if we're running on Python 2.4 |
587 # TODO: Use subprocess.Popen if we're running on Python 2.4 |
587 if options.debug: |
588 if options.debug: |
609 try: |
610 try: |
610 output = '' |
611 output = '' |
611 proc.tochild.close() |
612 proc.tochild.close() |
612 output = proc.fromchild.read() |
613 output = proc.fromchild.read() |
613 ret = proc.wait() |
614 ret = proc.wait() |
614 if os.WIFEXITED(ret): |
615 if wifexited(ret): |
615 ret = os.WEXITSTATUS(ret) |
616 ret = os.WEXITSTATUS(ret) |
616 except Timeout: |
617 except Timeout: |
617 vlog('# Process %d timed out - killing it' % proc.pid) |
618 vlog('# Process %d timed out - killing it' % proc.pid) |
618 ret = cleanup() |
619 ret = cleanup() |
619 output += ("\n### Abort: timeout after %d seconds.\n" |
620 output += ("\n### Abort: timeout after %d seconds.\n" |