mirror of https://gitee.com/openkylin/qemu.git
docker: Terminate instances at SIGTERM and SIGHUP
Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <1474429768-25027-9-git-send-email-famz@redhat.com> Reviewed-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
ec960b9a73
commit
97cba1a1d1
|
@ -21,6 +21,7 @@
|
|||
import argparse
|
||||
import tempfile
|
||||
import re
|
||||
import signal
|
||||
from tarfile import TarFile, TarInfo
|
||||
from StringIO import StringIO
|
||||
from shutil import copy, rmtree
|
||||
|
@ -101,6 +102,8 @@ def __init__(self):
|
|||
self._command = _guess_docker_command()
|
||||
self._instances = []
|
||||
atexit.register(self._kill_instances)
|
||||
signal.signal(signal.SIGTERM, self._kill_instances)
|
||||
signal.signal(signal.SIGHUP, self._kill_instances)
|
||||
|
||||
def _do(self, cmd, quiet=True, infile=None, **kwargs):
|
||||
if quiet:
|
||||
|
@ -133,7 +136,7 @@ def clean(self):
|
|||
self._do_kill_instances(False, False)
|
||||
return 0
|
||||
|
||||
def _kill_instances(self):
|
||||
def _kill_instances(self, *args, **kwargs):
|
||||
return self._do_kill_instances(True)
|
||||
|
||||
def _output(self, cmd, **kwargs):
|
||||
|
|
Loading…
Reference in New Issue