diff --git a/tests/clickhouse-test b/tests/clickhouse-test index 9f66f49837f..1175d8342b1 100755 --- a/tests/clickhouse-test +++ b/tests/clickhouse-test @@ -1031,7 +1031,24 @@ class TestCase: if proc: if proc.returncode is None: try: - proc.kill() + pgid = os.getpgid(proc.pid) + # NOTE: this still may leave some processes, that had been + # created by timeout(1), since it also creates new process + # group. But this should not be a problem with default + # options, since the default time for each test is 10min, + # and this is way more bigger then the timeout for each + # timeout(1) invocation. + # + # But as a workaround we are sending SIGTERM first, and + # only after SIGKILL, that way timeout(1) will have an + # ability to terminate childrens (though not always since + # signals are asynchronous). + os.killpg(pgid, signal.SIGTERM) + # This may not be enough, but this is at least something + # (and anyway it is OK to spend 0.1 second more in case of + # test timeout). + sleep(0.1) + os.killpg(pgid, signal.SIGKILL) except OSError as e: if e.errno != ESRCH: raise @@ -1307,7 +1324,7 @@ class TestCase: command = pattern.format(**params) - proc = Popen(command, shell=True, env=os.environ) + proc = Popen(command, shell=True, env=os.environ, start_new_session=True) while ( datetime.now() - start_time