summaryrefslogtreecommitdiffstats
path: root/usr.sbin/cron/cron
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2009-11-25 15:12:24 +0000
committerattilio <attilio@FreeBSD.org>2009-11-25 15:12:24 +0000
commit99524169bf3f72fffa8e41ace1a952854e3f97d3 (patch)
treef308da7e1d86252ddb2bfef1aafa5f589034f693 /usr.sbin/cron/cron
parentc984dc56360945b3348330530b2cec41b26e99e5 (diff)
downloadFreeBSD-src-99524169bf3f72fffa8e41ace1a952854e3f97d3.zip
FreeBSD-src-99524169bf3f72fffa8e41ace1a952854e3f97d3.tar.gz
Avoid sshd, cron, syslogd and inetd to be killed under high-pressure swap
environments. Please note that this can't be done while such processes run in jails. Note: in future it would be interesting to find a way to do that selectively for any desired proccess (choosen by user himself), probabilly via a ptrace interface or whatever. Obtained from: Sandvine Incorporated Reviewed by: emaste, arch@ Sponsored by: Sandvine Incorporated MFC: 1 month
Diffstat (limited to 'usr.sbin/cron/cron')
-rw-r--r--usr.sbin/cron/cron/cron.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/usr.sbin/cron/cron/cron.c b/usr.sbin/cron/cron/cron.c
index 101989c..52cdcc8 100644
--- a/usr.sbin/cron/cron/cron.c
+++ b/usr.sbin/cron/cron/cron.c
@@ -24,6 +24,7 @@ static const char rcsid[] =
#include "cron.h"
+#include <sys/mman.h>
#include <sys/signal.h>
#if SYS_TIME_H
# include <sys/time.h>
@@ -134,6 +135,9 @@ main(argc, argv)
}
}
+ if (madvise(NULL, 0, MADV_PROTECT) != 0)
+ log_it("CRON", getpid(), "WARNING", "madvise() failed");
+
pidfile_write(pfh);
database.head = NULL;
database.tail = NULL;
OpenPOWER on IntegriCloud