chiark / gitweb /
util: minor tweaks to disable_core_dumps()
authorLennart Poettering <lennart@poettering.net>
Wed, 10 Jan 2018 17:37:54 +0000 (18:37 +0100)
committerSven Eden <yamakuzure@gmx.net>
Wed, 30 May 2018 05:50:04 +0000 (07:50 +0200)
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
src/basic/util.h

index f60f60b02cbc4c71e46349a20aff009d2884bfcf..e23266ba346876d347a6103d8dc6fefd8823d63d 100644 (file)
@@ -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");
 }
index 643ce3bc4f87d031863cecfde5e3dd64c64846ca..de042509f88618d65083aa70cfbef96cd91981ce 100644 (file)
@@ -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);