From 99524169bf3f72fffa8e41ace1a952854e3f97d3 Mon Sep 17 00:00:00 2001 From: attilio Date: Wed, 25 Nov 2009 15:12:24 +0000 Subject: 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 --- crypto/openssh/sshd.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'crypto/openssh') diff --git a/crypto/openssh/sshd.c b/crypto/openssh/sshd.c index 249e20f..422f0cb 100644 --- a/crypto/openssh/sshd.c +++ b/crypto/openssh/sshd.c @@ -47,6 +47,7 @@ __RCSID("$FreeBSD$"); #include #include +#include #include #ifdef HAVE_SYS_STAT_H # include @@ -1293,6 +1294,10 @@ main(int ac, char **av) /* Initialize configuration options to their default values. */ initialize_server_options(&options); + /* Avoid killing the process in high-pressure swapping environments. */ + if (madvise(NULL, 0, MADV_PROTECT) != 0) + debug("madvise(): %.200s", strerror(errno)); + /* Parse command-line arguments. */ while ((opt = getopt(ac, av, "f:p:b:k:h:g:u:o:C:dDeiqrtQRT46")) != -1) { switch (opt) { -- cgit v1.1