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 --- 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