commit 864c852d0d90180c848c5fd20355fbe21769c78f Author: Mikolaj Golub Date: Sun Feb 12 19:54:29 2012 +0200 If permitted protect the supervisor against pageout kill. Suggested by: Andrey Zonov MFC after: 2 weeks diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c index 8ec294e..75192f0 100644 --- a/usr.sbin/daemon/daemon.c +++ b/usr.sbin/daemon/daemon.c @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include @@ -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