Author: trociny
Date: Sun Feb 19 10:38:55 2012
New Revision: 231912
URL: http://svn.freebsd.org/changeset/base/231912

Log:
  If permitted protect the supervisor against pageout kill.
  
  Suggested by: Andrey Zonov <andrey zonov org>
  MFC after:    2 weeks

Modified:
  head/usr.sbin/daemon/daemon.c

Modified: head/usr.sbin/daemon/daemon.c
==============================================================================
--- head/usr.sbin/daemon/daemon.c       Sun Feb 19 10:36:29 2012        
(r231911)
+++ head/usr.sbin/daemon/daemon.c       Sun Feb 19 10:38:55 2012        
(r231912)
@@ -32,6 +32,7 @@
 __FBSDID("$FreeBSD$");
 
 #include <sys/param.h>
+#include <sys/mman.h>
 #include <sys/wait.h>
 
 #include <err.h>
@@ -138,6 +139,12 @@ main(int argc, char *argv[])
                sigaddset(&mask, SIGCHLD);
                if (sigprocmask(SIG_SETMASK, &mask, &oldmask) == -1)
                        err(1, "sigprocmask");
+               /*
+                * Try to protect against pageout kill. Ignore the
+                * error, madvise(2) will fail only if a process does
+                * not have superuser privileges.
+                */
+               (void)madvise(NULL, 0, MADV_PROTECT);
 restart:
                /*
                 * Spawn a child to exec the command, so in the parent
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to