From 38db5e1f2fa613733e0902599bcdf6ea30d98086 Mon Sep 17 00:00:00 2001 From: Dhanuka Warusadura Date: Mon, 17 Apr 2023 13:00:39 +0530 Subject: [PATCH] criu-ns: Add support for older Python version in CI These changes remove and update the changes introduced in 7177938e60b81752a44a8116b3e7e399c24c4fcb in favor of the Python version in CI. os.waitstatus_to_exitcode() function appeared in Python 3.9 Related to: #1909 Signed-off-by: Dhanuka Warusadura --- scripts/criu-ns | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/scripts/criu-ns b/scripts/criu-ns index d4d867b66..4c032aa14 100755 --- a/scripts/criu-ns +++ b/scripts/criu-ns @@ -71,7 +71,19 @@ def _wait_for_process_status(criu_pid): try: (pid, status) = os.wait() if pid == criu_pid: - return os.waitstatus_to_exitcode(status) + # The following code block is based on + # os.waitstatus_to_exitcode() introduced in Python 3.9 + # and we implement this for comparability with older + # versions of Python. + if os.WIFSIGNALED(status): + return os.WTERMSIG(status) + elif os.WIFEXITED(status): + return os.WEXITSTATUS(status) + elif os.WIFSTOPPED(status): + return os.WSTOPSIG(status) + else: + raise Exception("CRIU was terminated by an " + "unidentified reason") except OSError: return -251