Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 19 Feb 2012 10:38:56 +0000 (UTC)
From:      Mikolaj Golub <trociny@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r231912 - head/usr.sbin/daemon
Message-ID:  <201202191038.q1JAcuHd076444@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202191038.q1JAcuHd076444>