From ccd13887caac76d4e3416dbf0fce8d08ad86d594 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Miros=C5=82aw?= Date: Fri, 21 Apr 2023 15:57:32 +0200 Subject: [PATCH] zdtm: Treat ESRCH from kill() as success. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes failure to clean up after a failed test, where CRIU didn't start properly. ``` ===================== Run zdtm/transition/socket-tcp in h ====================== Start test ./socket-tcp --pidfile=socket-tcp.pid --outfile=socket-tcp.out Traceback (most recent call last): File "/tmp/vex/work/zdtm_py.par/google3/third_party/criu/v3_17/zdtm_py.py", line 1906, in do_run_test cr(cr_api, t, opts) File "/tmp/vex/work/zdtm_py.par/google3/third_party/criu/v3_17/zdtm_py.py", line 1584, in cr cr_api.dump("dump") File "/tmp/vex/work/zdtm_py.par/google3/third_party/criu/v3_17/zdtm_py.py", line 1386, in dump self.__dump_process = self.__criu_act(action, File "/tmp/vex/work/zdtm_py.par/google3/third_party/criu/v3_17/zdtm_py.py", line 1224, in __criu_act raise test_fail_exc("CRIU %s" % action) test_fail_exc: CRIU dump During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 182, in run_filename_from_loader_as_main File "", line 34, in _run_code_in_main File "/tmp/vex/work/zdtm_py.par/google3/third_party/criu/v3_17/zdtm_py.py", line 2790, in fork_zdtm() File "/tmp/vex/work/zdtm_py.par/google3/third_party/criu/v3_17/zdtm_py.py", line 2782, in fork_zdtm do_run_test(tinfo[0], tinfo[1], tinfo[2], tinfo[3]) File "/tmp/vex/work/zdtm_py.par/google3/third_party/criu/v3_17/zdtm_py.py", line 1922, in do_run_test t.kill() File "/tmp/vex/work/zdtm_py.par/google3/third_party/criu/v3_17/zdtm_py.py", line 509, in kill os.kill(int(self.__pid), sig) ProcessLookupError: [Errno 3] No such process ``` Signed-off-by: Michał Mirosław --- test/zdtm.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/zdtm.py b/test/zdtm.py index bc14e3f73e6..d9aaa5e9560 100755 --- a/test/zdtm.py +++ b/test/zdtm.py @@ -507,8 +507,14 @@ def kill(self, sig=signal.SIGKILL): self.__freezer.thaw() if self.__pid: print("Send the %d signal to %s" % (sig, self.__pid)) - os.kill(int(self.__pid), sig) - self.gone(sig == signal.SIGKILL) + try: + os.kill(int(self.__pid), sig) + except ProcessLookupError: + # Prevent gone() calling waitpid(). + self.auto_reap = True + self.gone(True) + else: + self.gone(sig == signal.SIGKILL) self.__flavor.fini()