From: Hari Mishal <harimishal1@gmail.com>
To: SJ Park <sj@kernel.org>, Shuah Khan <shuah@kernel.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Hari Mishal <harimishal1@gmail.com>,
damon@lists.linux.dev, linux-mm@kvack.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] selftests/damon/sysfs.py: clean up sh processes used for obsolete_target test
Date: Tue, 21 Jul 2026 21:04:04 +0200 [thread overview]
Message-ID: <20260721190404.135937-1-harimishal1@gmail.com> (raw)
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
next reply other threads:[~2026-07-21 19:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 19:04 Hari Mishal [this message]
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
2026-07-22 19:15 ` Hari Mishal
2026-07-23 0:22 ` SJ Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260721190404.135937-1-harimishal1@gmail.com \
--to=harimishal1@gmail.com \
--cc=damon@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shuah@kernel.org \
--cc=sj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®