DAMON development mailing list
 help / color / mirror / Atom feed
* [PATCH] selftests/damon/sysfs.py: clean up sh processes used for obsolete_target test
@ 2026-07-21 19:04 Hari Mishal
  2026-07-21 23:51 ` SJ Park
  2026-07-22  1:23 ` [PATCH v2] " Hari Mishal
  0 siblings, 2 replies; 5+ messages in thread
From: Hari Mishal @ 2026-07-21 19:04 UTC (permalink / raw)
  To: SJ Park, Shuah Khan
  Cc: Greg Kroah-Hartman, Hari Mishal, damon, linux-mm, linux-kselftest,
	linux-kernel

The obsolete_target test spawns three sh processes and uses their pids
as DAMON monitoring targets.  These processes are created without their
own stdin, so they inherit the test program's stdin, and they are never
waited on or told to exit.  As a result, they are left running (or
become zombies) as orphaned children after the test program exits.

Give each sh process its own dedicated stdin pipe instead of inheriting
the test program's, and after the targets are no longer needed,
communicate() with each process to close its stdin.  This sends EOF to
the shell, which makes it exit, and communicate() then reaps the
process.

Signed-off-by: Hari Mishal <harimishal1@gmail.com>
---
 tools/testing/selftests/damon/sysfs.py | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py
index aa03a1187489..d3d50a5a1d56 100755
--- a/tools/testing/selftests/damon/sysfs.py
+++ b/tools/testing/selftests/damon/sysfs.py
@@ -328,11 +328,14 @@ def main():
     kdamonds.stop()
 
     # test obsolete_target.
-    proc1 = subprocess.Popen(['sh'], stdout=subprocess.PIPE,
+    proc1 = subprocess.Popen(['sh'], stdin=subprocess.PIPE,
+                             stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
-    proc2 = subprocess.Popen(['sh'], stdout=subprocess.PIPE,
+    proc2 = subprocess.Popen(['sh'], stdin=subprocess.PIPE,
+                             stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
-    proc3 = subprocess.Popen(['sh'], stdout=subprocess.PIPE,
+    proc3 = subprocess.Popen(['sh'], stdin=subprocess.PIPE,
+                             stdout=subprocess.PIPE,
                              stderr=subprocess.PIPE)
     kdamonds = _damon_sysfs.Kdamonds(
             [_damon_sysfs.Kdamond(
@@ -356,5 +359,8 @@ def main():
     assert_ctxs_committed(kdamonds)
     kdamonds.stop()
 
+    for proc in (proc1, proc2, proc3):
+        proc.communicate()
+
 if __name__ == '__main__':
     main()
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-22 13:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 19:04 [PATCH] selftests/damon/sysfs.py: clean up sh processes used for obsolete_target test Hari Mishal
2026-07-21 23:51 ` SJ Park
2026-07-22  1:23 ` [PATCH v2] " Hari Mishal
2026-07-22  3:38   ` SJ Park
2026-07-22 13:48     ` SJ Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox