From 5b0c3870239144ec042d37fe5b6b01bf5b339353 Mon Sep 17 00:00:00 2001 From: Chris Kuehl Date: Fri, 26 Aug 2016 13:04:46 -0700 Subject: [PATCH 1/2] Make sure to use /bin/bash for exit_status_test --- tests/exit_status_test.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/exit_status_test.py b/tests/exit_status_test.py index bb7be1d..8befbbf 100644 --- a/tests/exit_status_test.py +++ b/tests/exit_status_test.py @@ -1,3 +1,4 @@ +import distutils.spawn import signal from subprocess import Popen @@ -26,6 +27,11 @@ def test_exit_status_terminated_by_signal(signal): """dumb-init should exit with status 128 + signal when the child process is terminated by a signal. """ - proc = Popen(('dumb-init', 'sh', '-c', 'kill -{0} $$'.format(signal))) + # We need to make sure not to use the built-in kill (if on Bash): + # https://github.com/Yelp/dumb-init/issues/115 + proc = Popen(('dumb-init', 'sh', '-c', '{0} -{1} $$'.format( + distutils.spawn.find_executable('kill'), + signal, + ))) proc.wait() assert proc.returncode == 128 + signal From 9398a4d0d0c6c2b08fe98b84ee4f9fef351233da Mon Sep 17 00:00:00 2001 From: Chris Kuehl Date: Fri, 26 Aug 2016 13:22:55 -0700 Subject: [PATCH 2/2] Have Python kill itself instead of using /bin/kill This is probably less fragile --- tests/exit_status_test.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/exit_status_test.py b/tests/exit_status_test.py index 8befbbf..f67a17c 100644 --- a/tests/exit_status_test.py +++ b/tests/exit_status_test.py @@ -1,5 +1,5 @@ -import distutils.spawn import signal +import sys from subprocess import Popen import pytest @@ -18,7 +18,7 @@ def test_exit_status_regular_exit(exit_status): @pytest.mark.parametrize('signal', [ signal.SIGTERM, - signal.SIGINT, + signal.SIGHUP, signal.SIGQUIT, signal.SIGKILL, ]) @@ -27,10 +27,9 @@ def test_exit_status_terminated_by_signal(signal): """dumb-init should exit with status 128 + signal when the child process is terminated by a signal. """ - # We need to make sure not to use the built-in kill (if on Bash): + # We use Python because sh is "dash" on Debian and "bash" on others. # https://github.com/Yelp/dumb-init/issues/115 - proc = Popen(('dumb-init', 'sh', '-c', '{0} -{1} $$'.format( - distutils.spawn.find_executable('kill'), + proc = Popen(('dumb-init', sys.executable, '-c', 'import os; os.kill(os.getpid(), {0})'.format( signal, ))) proc.wait()