diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c index b1773bfdd2af..54d312358617 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