[PATCH v2] selftests/damon/sysfs.py: clean up sh processes used for obsolete_target test

From: Hari Mishal

Date: Tue Jul 21 2026 - 21:24:02 EST


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.

Signed-off-by: Hari Mishal <harimishal1@xxxxxxxxx>
---
v2: 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 aa03a1187489..bdb37eb1d26f 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -356,5 +356,9 @@ def main():
assert_ctxs_committed(kdamonds)
kdamonds.stop()

+ for proc in (proc1, proc2, proc3):
+ proc.terminate()
+ proc.communicate()
+
if __name__ == '__main__':
main()
--
2.43.0