diff --git a/scriptworker_client/src/scriptworker_client/utils.py b/scriptworker_client/src/scriptworker_client/utils.py index 0bb8c464e..43adf7682 100644 --- a/scriptworker_client/src/scriptworker_client/utils.py +++ b/scriptworker_client/src/scriptworker_client/utils.py @@ -13,6 +13,7 @@ import os import random import shutil +import signal import tempfile from asyncio.subprocess import PIPE from contextlib import contextmanager @@ -174,9 +175,7 @@ async def run_command( env=None, exception=None, expected_exit_codes=(0,), - # https://stackoverflow.com/questions/18731791/determining-if-a-python-subprocess-segmentation-faults - # Shell exit codes range from 0 to 255. Therefore 245 == -11, 241 == -15 - copy_exit_codes=(245, 241), + copy_exit_codes=(-signal.SIGTERM, -signal.SIGSEGV), output_log_on_exception=False, ): """Run a command using ``asyncio.create_subprocess_exec``. @@ -209,7 +208,7 @@ async def run_command( Defaults to ``(0, )``. copy_exit_codes (list, optional): the list of exit codes that we set ``exit_code`` to if ``exception`` is an instance of - ``ClientError``. Defaults to ``(245, 241)``. + ``ClientError``. Defaults to ``(-15, -11)``. output_log_on_exception (bool, optional): log the output log if we're raising an exception. diff --git a/scriptworker_client/tests/test_utils.py b/scriptworker_client/tests/test_utils.py index 335ab9cf4..b371c58bd 100644 --- a/scriptworker_client/tests/test_utils.py +++ b/scriptworker_client/tests/test_utils.py @@ -171,8 +171,8 @@ def test_get_log_filehandle(path, tmpdir): True, ), ( - ["bash", "-c", ">&2 echo bar && echo foo && exit -11"], - 245, + ["bash", "-c", ">&2 echo bar && echo foo && kill -11 $$"], + -11, ["foo\nbar\n", "bar\nfoo\n"], TaskError, True,