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.
This commit is contained in:
Lennart Poettering
2018-01-10 18:44:09 +01:00
parent 47cf8ff206
commit e557b1a655
5 changed files with 13 additions and 8 deletions
+9 -3
View File
@@ -618,7 +618,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");
}
+1 -1
View File
@@ -192,4 +192,4 @@ int version(void);
int str_verscmp(const char *s1, const char *s2);
void disable_core_dumps(void);
void disable_coredumps(void);