[LTP] [PATCH] pty09: Cap RLIMIT_NOFILE-based slave PTY opens
Runli
mingyu.he@shopee.com
Thu Jul 9 09:49:23 CEST 2026
pty09 derives the number of slave PTY opens from RLIMIT_NOFILE. When the
limit is very large, for example 1048576, the test tries to open nearly
one million slave PTYs on the same master. That makes the workload depend
on the caller's file descriptor limit instead of the PTY behavior being
tested, and can turn a working PTY open path into a timeout-driven TBROK.
The test only needs to verify that a slave pseudo-terminal can be opened
multiple times in parallel. Cap the number of slave opens at 4096 so the
test remains representative and deterministic even when RLIMIT_NOFILE is
set unusually high.
Fixes: 20aa13dbd8a68 ("Add pty09 test")
Signed-off-by: Runli <mingyu.he@shopee.com>
---
testcases/kernel/pty/pty09.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/testcases/kernel/pty/pty09.c b/testcases/kernel/pty/pty09.c
index f3ade2381..7eff1ad54 100644
--- a/testcases/kernel/pty/pty09.c
+++ b/testcases/kernel/pty/pty09.c
@@ -14,6 +14,8 @@
static int masterfd = -1;
+#define MAX_SLAVE_OPENS 4096
+
static unsigned int count_avail_pid(void)
{
DIR *dir;
@@ -31,6 +33,8 @@ static unsigned int count_avail_pid(void)
SAFE_CLOSEDIR(dir);
max_pid_num = limit.rlim_cur - count;
+ if (max_pid_num > MAX_SLAVE_OPENS)
+ max_pid_num = MAX_SLAVE_OPENS;
tst_res(TINFO, "Available number of pids: %u", max_pid_num);
--
2.47.0
More information about the ltp
mailing list