From e9ac3d457a6b01566cef008dae9ab77059a8652a Mon Sep 17 00:00:00 2001 From: cah Date: Tue, 4 Oct 2022 08:53:45 +0200 Subject: [PATCH] Kill docker image on SIGTERM. --- cdist | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cdist b/cdist index 49589b7..f814ba8 100755 --- a/cdist +++ b/cdist @@ -29,6 +29,7 @@ import os from pathlib import Path import platform import re +import signal import shlex import shutil import subprocess @@ -549,6 +550,10 @@ class DockerTarget(Target): if config.has('docker_hub_repository'): tag = '%s:%s' % (config.get('docker_hub_repository'), tag) + def signal_handler(signum, frame): + raise Error('Killed') + signal.signal(signal.SIGTERM, signal_handler) + self.container = command_and_read('%s run %s %s -itd %s /bin/bash' % (config.docker(), self._user_tag(), opts, tag))[0].strip() def command(self, cmd): -- 2.30.2