From: Tom Hromatka Date: Tue, 1 Apr 2025 17:41:01 +0000 (+0000) Subject: ftests: Retry getting pid of sleep process X-Git-Tag: v3.2.0~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=36763c9f158bf8a8ca65d4701f1f2ef8ef83d79c;p=thirdparty%2Flibcgroup.git ftests: Retry getting pid of sleep process The ftests framework uses sleeping processes to test various cgroup features. Sometimes ps throws an error when we try to enumerate processes via `ps x` within an lxc container. The error thrown by ps is as follows: Signal 21 (TTIN) caught by ps (3.3.17). ps:ps/display.c:70: please report this bug Fix this by adding a retry loop for the ps command, as it usually works in a subsequent pass. Signed-off-by: Tom Hromatka Acked-by: Kamalesh Babulal --- diff --git a/tests/ftests/process.py b/tests/ftests/process.py index 021d9f29..6833e7b4 100644 --- a/tests/ftests/process.py +++ b/tests/ftests/process.py @@ -73,17 +73,25 @@ class Process(object): ''.format(sleep_time) ) - if config.args.container: - pid = config.container.run(cmd, shell_bool=True) - else: - pid = Run.run(cmd, shell_bool=True) + for i in range(3): + try: + if config.args.container: + pid = config.container.run(cmd, shell_bool=True) + break + else: + pid = Run.run(cmd, shell_bool=True) + break + except RunError: + # On some setups, lxc will throw Signal 21 (TTIN) caught by ps (3.3.17). + # Retrying the request usually works. + pass - for _pid in pid.splitlines(): - self.children_pids.append(int(_pid)) + for _pid in pid.splitlines(): + self.children_pids.append(int(_pid)) - if pid.find('\n') >= 0: - # The second pid in the list contains the actual perl process - pid = pid.splitlines()[1] + if pid.find('\n') >= 0: + # The second pid in the list contains the actual perl process + pid = pid.splitlines()[1] if pid == '' or int(pid) <= 0: raise ValueError(