]> git.ipfire.org Git - thirdparty/libcgroup.git/commitdiff
ftests: Retry getting pid of sleep process
authorTom Hromatka <tom.hromatka@oracle.com>
Tue, 1 Apr 2025 17:41:01 +0000 (17:41 +0000)
committerTom Hromatka <tom.hromatka@oracle.com>
Wed, 2 Apr 2025 18:44:17 +0000 (12:44 -0600)
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 <tom.hromatka@oracle.com>
Acked-by: Kamalesh Babulal <kamalesh.babulal@oracle.com>
tests/ftests/process.py

index 021d9f291c93e157edc6a3a4432e7393f39118de..6833e7b4c746e5e384c7a29c8e022e7497a8ff47 100644 (file)
@@ -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(