summaryrefslogtreecommitdiff
path: root/lib/daemon.c
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-05-11 10:56:10 -0700
committerBen Pfaff <blp@nicira.com>2010-05-13 09:45:21 -0700
commit7c2dd4c64823397d82d7d1c4e44f6a420df52aa6 (patch)
tree8cbe52a980a4c1ee8b11821a81e8abab292b271a /lib/daemon.c
parente2bfacb6e490bb571f2fbd243c7a2d4658149fba (diff)
downloadopenvswitch-7c2dd4c64823397d82d7d1c4e44f6a420df52aa6.tar.gz
daemon: Allow monitored daemon to dump core no more than once.
If the monitored daemon dumps core frequently, then this can quickly exhaust the host's disk space. This commit limits core dumps to at most one per monitored session (typically, once per boot).
Diffstat (limited to 'lib/daemon.c')
-rw-r--r--lib/daemon.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/daemon.c b/lib/daemon.c
index 081912b12..292be1465 100644
--- a/lib/daemon.c
+++ b/lib/daemon.c
@@ -353,6 +353,18 @@ monitor_daemon(pid_t daemon_pid)
free(s);
if (should_restart(status)) {
+ if (WCOREDUMP(status)) {
+ /* Disable further core dumps to save disk space. */
+ struct rlimit r;
+
+ r.rlim_cur = 0;
+ r.rlim_max = 0;
+ if (setrlimit(RLIMIT_CORE, &r) == -1) {
+ VLOG_WARN("failed to disable core dumps: %s",
+ strerror(errno));
+ }
+ }
+
VLOG_ERR("%s, restarting", status_msg);
daemon_pid = fork_and_wait_for_startup(&daemonize_fd);
if (!daemon_pid) {