[PATCH 4/7] selftests/damon/sysfs.py: clean up sh processes used for obsolete_target test
From: SJ Park
Date: Mon Aug 31 2026 - 12:53:33 EST
From: Hari Mishal <harimishal1@xxxxxxxxx>
The obsolete_target test spawns three sh processes and uses their pids
as DAMON monitoring targets. These processes are never terminated or
waited on, so they are left running (or become zombies) as orphaned
children after the test program exits.
Terminate each process and communicate() with it after the targets are
no longer needed, so it exits and gets reaped instead of being leaked.
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Signed-off-by: Hari Mishal <harimishal1@xxxxxxxxx>
Reviewed-by: SJ Park <sj@xxxxxxxxxx>
Signed-off-by: SJ Park <sj@xxxxxxxxxx>
---
Changes from v2
- v2: https://lore.kernel.org/20260722012349.9738-1-harimishal1@xxxxxxxxx
- Collect R-b: from SJ.
- Rebase to latest mm-new.
Changes from v1
- v1: https://lore.kernel.org/20260721190404.135937-1-harimishal1@xxxxxxxxx
- Terminate each sh process directly instead of giving it its own stdin
pipe to close, dropping the stdin=PIPE changes and shrinking the diff.
tools/testing/selftests/damon/sysfs.py | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
index 3ffa054b63867..88a26422ff44c 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -385,6 +385,10 @@ def main():
assert_ctxs_committed(kdamonds)
kdamonds.stop()
+ for proc in (proc1, proc2, proc3):
+ proc.terminate()
+ proc.communicate()
+
test_memcg_filter_memcg_path_staging()
if __name__ == '__main__':
--
2.47.3