[LTP] [PATCH] waitid10: Fix when coredumps are piped

Cyril Hrubis chrubis@suse.cz
Mon Mar 21 14:38:49 CET 2022


When coredumps are piped into a stdin of a program (the core_pattern
starts with '|') the RLIMIT_CORE limits are not enforced.

This fixes the test expectation in the corner case that rlim_cur and
rlim_max for RLIMIT_CORE are both set to 0 but the core pattern is set
to dump core into a pipe where we previously assumed the core wouldn't
be dumped.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/waitid/waitid10.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/waitid/waitid10.c b/testcases/kernel/syscalls/waitid/waitid10.c
index 869ef18bd..e75edd07e 100644
--- a/testcases/kernel/syscalls/waitid/waitid10.c
+++ b/testcases/kernel/syscalls/waitid/waitid10.c
@@ -45,14 +45,17 @@ static void run(void)
 static void setup(void)
 {
 	struct rlimit rlim;
+	char c;
 
 	SAFE_GETRLIMIT(RLIMIT_CORE, &rlim);
+	SAFE_FILE_SCANF("/proc/sys/kernel/core_pattern", "%c", &c);
 
 	if (rlim.rlim_cur)
 		return;
 
 	if (!rlim.rlim_max) {
-		core_dumps = 0;
+		if (c != '|')
+			core_dumps = 0;
 		return;
 	}
 
-- 
2.34.1



More information about the ltp mailing list