diff options
Diffstat (limited to 'scripts/runqemu')
| -rwxr-xr-x | scripts/runqemu | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/scripts/runqemu b/scripts/runqemu index 0cce8bb96a..5a98abfffe 100755 --- a/scripts/runqemu +++ b/scripts/runqemu | |||
| @@ -211,7 +211,7 @@ class BaseConfig(object): | |||
| 211 | self.mac_slirp = "52:54:00:12:35:" | 211 | self.mac_slirp = "52:54:00:12:35:" |
| 212 | # pid of the actual qemu process | 212 | # pid of the actual qemu process |
| 213 | self.qemu_environ = os.environ.copy() | 213 | self.qemu_environ = os.environ.copy() |
| 214 | self.qemupid = None | 214 | self.qemuprocess = None |
| 215 | # avoid cleanup twice | 215 | # avoid cleanup twice |
| 216 | self.cleaned = False | 216 | self.cleaned = False |
| 217 | # Files to cleanup after run | 217 | # Files to cleanup after run |
| @@ -1512,7 +1512,7 @@ class BaseConfig(object): | |||
| 1512 | for descriptor in self.portlocks.values(): | 1512 | for descriptor in self.portlocks.values(): |
| 1513 | pass_fds.append(descriptor.fileno()) | 1513 | pass_fds.append(descriptor.fileno()) |
| 1514 | process = subprocess.Popen(cmds, stderr=subprocess.PIPE, pass_fds=pass_fds, env=self.qemu_environ) | 1514 | process = subprocess.Popen(cmds, stderr=subprocess.PIPE, pass_fds=pass_fds, env=self.qemu_environ) |
| 1515 | self.qemupid = process.pid | 1515 | self.qemuprocess = process |
| 1516 | retcode = process.wait() | 1516 | retcode = process.wait() |
| 1517 | if retcode: | 1517 | if retcode: |
| 1518 | if retcode == -signal.SIGTERM: | 1518 | if retcode == -signal.SIGTERM: |
| @@ -1528,6 +1528,15 @@ class BaseConfig(object): | |||
| 1528 | signal.signal(signal.SIGTERM, signal.SIG_IGN) | 1528 | signal.signal(signal.SIGTERM, signal.SIG_IGN) |
| 1529 | 1529 | ||
| 1530 | logger.info("Cleaning up") | 1530 | logger.info("Cleaning up") |
| 1531 | |||
| 1532 | if self.qemuprocess: | ||
| 1533 | try: | ||
| 1534 | # give it some time to shut down, ignore return values and output | ||
| 1535 | self.qemuprocess.send_signal(signal.SIGTERM) | ||
| 1536 | self.qemuprocess.communicate(timeout=5) | ||
| 1537 | except subprocess.TimeoutExpired: | ||
| 1538 | self.qemuprocess.kill() | ||
| 1539 | |||
| 1531 | with open('/proc/uptime', 'r') as f: | 1540 | with open('/proc/uptime', 'r') as f: |
| 1532 | uptime_seconds = f.readline().split()[0] | 1541 | uptime_seconds = f.readline().split()[0] |
| 1533 | logger.info('Host uptime: %s\n' % uptime_seconds) | 1542 | logger.info('Host uptime: %s\n' % uptime_seconds) |
| @@ -1555,6 +1564,9 @@ class BaseConfig(object): | |||
| 1555 | else: | 1564 | else: |
| 1556 | shutil.rmtree(ent) | 1565 | shutil.rmtree(ent) |
| 1557 | 1566 | ||
| 1567 | # Deliberately ignore the return code of 'tput smam'. | ||
| 1568 | subprocess.call(["tput", "smam"]) | ||
| 1569 | |||
| 1558 | self.cleaned = True | 1570 | self.cleaned = True |
| 1559 | 1571 | ||
| 1560 | def run_bitbake_env(self, mach=None): | 1572 | def run_bitbake_env(self, mach=None): |
| @@ -1631,12 +1643,8 @@ def main(): | |||
| 1631 | subprocess.check_call([renice, str(os.getpid())]) | 1643 | subprocess.check_call([renice, str(os.getpid())]) |
| 1632 | 1644 | ||
| 1633 | def sigterm_handler(signum, frame): | 1645 | def sigterm_handler(signum, frame): |
| 1634 | logger.info("SIGTERM received") | 1646 | logger.info("Received signal: %s" % (signum)) |
| 1635 | if config.qemupid: | ||
| 1636 | os.kill(config.qemupid, signal.SIGTERM) | ||
| 1637 | config.cleanup() | 1647 | config.cleanup() |
| 1638 | # Deliberately ignore the return code of 'tput smam'. | ||
| 1639 | subprocess.call(["tput", "smam"]) | ||
| 1640 | signal.signal(signal.SIGTERM, sigterm_handler) | 1648 | signal.signal(signal.SIGTERM, sigterm_handler) |
| 1641 | 1649 | ||
| 1642 | config.check_args() | 1650 | config.check_args() |
| @@ -1658,8 +1666,6 @@ def main(): | |||
| 1658 | return 1 | 1666 | return 1 |
| 1659 | finally: | 1667 | finally: |
| 1660 | config.cleanup() | 1668 | config.cleanup() |
| 1661 | # Deliberately ignore the return code of 'tput smam'. | ||
| 1662 | subprocess.call(["tput", "smam"]) | ||
| 1663 | 1669 | ||
| 1664 | if __name__ == "__main__": | 1670 | if __name__ == "__main__": |
| 1665 | sys.exit(main()) | 1671 | sys.exit(main()) |
