diff options
author | trociny <trociny@FreeBSD.org> | 2012-02-19 10:38:55 +0000 |
---|---|---|
committer | trociny <trociny@FreeBSD.org> | 2012-02-19 10:38:55 +0000 |
commit | faf7be49ae44f552b4fc94ec07863c71eedc9668 (patch) | |
tree | 7628ca58a48f85b0b06c2f42b12f3ff6cbb87868 /usr.sbin | |
parent | 7e6fe25ca591804e5f55ce11640226a89c78d6ed (diff) | |
download | FreeBSD-src-faf7be49ae44f552b4fc94ec07863c71eedc9668.zip FreeBSD-src-faf7be49ae44f552b4fc94ec07863c71eedc9668.tar.gz |
If permitted protect the supervisor against pageout kill.
Suggested by: Andrey Zonov <andrey zonov org>
MFC after: 2 weeks
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/daemon/daemon.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/usr.sbin/daemon/daemon.c b/usr.sbin/daemon/daemon.c index b1773bf..54d3123 100644 --- a/usr.sbin/daemon/daemon.c +++ b/usr.sbin/daemon/daemon.c @@ -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 |