[CRIU] [PATCH] restore: set the zero limit for RLIMIT_CORE

Andrey Vagin avagin at openvz.org
Fri Jul 12 05:50:52 EDT 2013


This should be done to prevent generating core files, if a process was
killed by SIGSEGV, SIGBUS, etc

https://bugzilla.openvz.org/show_bug.cgi?id=2655
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
 cr-restore.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/cr-restore.c b/cr-restore.c
index e9eac8d..1d014e1 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -737,8 +737,13 @@ static int restore_one_zombie(int pid, CoreEntry *core)
 	}
 
 	if (exit_code & 0x7f) {
+		struct rlimit rlim = {0, 0};
 		int signr;
 
+		/* prevent generating core files */
+		if (setrlimit(RLIMIT_CORE, &rlim))
+			pr_perror("Can't set the zero limit for core files");
+
 		signr = exit_code & 0x7F;
 		if (!sig_fatal(signr)) {
 			pr_warn("Exit with non fatal signal ignored\n");
-- 
1.8.3.1



More information about the CRIU mailing list