diff options
author | Fam Zheng <famz@redhat.com> | 2016-09-21 11:49:27 +0800 |
---|---|---|
committer | Fam Zheng <famz@redhat.com> | 2016-09-23 11:48:32 +0800 |
commit | 97cba1a1d1e62ea3e2718ad22188d10f2aa5478d (patch) | |
tree | 63472e3fbe28789691f5c956c34534c2ab1a7b04 | |
parent | ec960b9a73f48b8b0bc7d5d31a173e90bd38a290 (diff) |
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>
-rwxr-xr-x | tests/docker/docker.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tests/docker/docker.py b/tests/docker/docker.py index 71b0d27e18..37d83199e7 100755 --- a/tests/docker/docker.py +++ b/tests/docker/docker.py @@ -21,6 +21,7 @@ import uuid 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 @@ class Docker(object): 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 @@ class Docker(object): 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): |