From 5a98bb37ef28a1a0cfcb6676c469982d47997287 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 10 Jan 2018 18:37:54 +0100 Subject: util: minor tweaks to disable_core_dumps() First, let's rename it to disable_coredumps(), as in the rest of our codebase we spell it "coredump" rather than "core_dump", so let's stick to that. However, also log about failures to turn off core dumpling on LOG_DEBUG, because debug logging is always a good idea. --- src/basic/util.c | 12 +++++++++--- src/basic/util.h | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) (limited to 'src/basic') diff --git a/src/basic/util.c b/src/basic/util.c index f60f60b02..e23266ba3 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -628,7 +628,13 @@ int str_verscmp(const char *s1, const char *s2) { } /* Turn off core dumps but only if we're running outside of a container. */ -void disable_core_dumps(void) { - if (detect_container() <= 0) - (void) write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); +void disable_coredumps(void) { + int r; + + if (detect_container() > 0) + return; + + r = write_string_file("/proc/sys/kernel/core_pattern", "|/bin/false", 0); + if (r < 0) + log_debug_errno(r, "Failed to turn off coredumps, ignoring: %m"); } diff --git a/src/basic/util.h b/src/basic/util.h index 643ce3bc4..de042509f 100644 --- a/src/basic/util.h +++ b/src/basic/util.h @@ -206,4 +206,4 @@ int version(void); #endif // 0 int str_verscmp(const char *s1, const char *s2); -void disable_core_dumps(void); +void disable_coredumps(void); -- cgit v1.2.3