zdtm: Treat ESRCH from kill() as success.

This fixes a 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 ".../zdtm_py.py", line 1906, in do_run_test
    cr(cr_api, t, opts)
  File ".../zdtm_py.py", line 1584, in cr
    cr_api.dump("dump")
  File ".../zdtm_py.py", line 1386, in dump
    self.__dump_process = self.__criu_act(action,
  File ".../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 "<embedded module '_launcher'>", line 182, in run_filename_from_loader_as_main
  File "<embedded module '_launcher'>", line 34, in _run_code_in_main
  File ".../zdtm_py.py", line 2790, in <module>
    fork_zdtm()
  File ".../zdtm_py.py", line 2782, in fork_zdtm
    do_run_test(tinfo[0], tinfo[1], tinfo[2], tinfo[3])
  File ".../zdtm_py.py", line 1922, in do_run_test
    t.kill()
  File ".../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 <emmir@google.com>
This commit is contained in:
Michał Mirosław 2023-04-21 15:57:32 +02:00 committed by Andrei Vagin
parent c29c5a1df0
commit f6e820bedb

View file

@ -507,8 +507,15 @@ class zdtm_test:
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:
if sig != signal.SIGKILL:
raise
print("The process %s doesn't exist" % self.__pid)
self.gone(True)
else:
self.gone(sig == signal.SIGKILL)
self.__flavor.fini()