From fa653e4136d08e83d4f1d7dc4f415057920c8e33 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Wed, 6 May 2020 17:57:33 +0200 Subject: selftest/process_test: Fix output changing in new python version On older versions apparently upon child termination due to SIGINT subprocess.poll() returned 1. On new python versions (such as 3.8.2), -2 is returned, according to documentation: A negative value -N indicates that the child was terminated by signal N (Unix only). Let's catch the SIGINT in the child process and exit with a known 42 value to fix different behavior. Change-Id: I7949ff2b435e91e890061e6840b0f411f8b0a817 --- selftest/process_test/foo.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'selftest/process_test/foo.py') diff --git a/selftest/process_test/foo.py b/selftest/process_test/foo.py index 4abe887..0931c9b 100755 --- a/selftest/process_test/foo.py +++ b/selftest/process_test/foo.py @@ -3,7 +3,13 @@ import sys import atexit import time +import signal +def signal_handler(sig, frame): + print('SIGINT received') + sys.exit(42) + +signal.signal(signal.SIGINT, signal_handler) sys.stdout.write('foo stdout\n') sys.stderr.write('foo stderr\n') -- cgit v1.2.3