If permitted protect the supervisor against pageout kill.

Suggested by:	Andrey Zonov <andrey zonov org>
MFC after:	2 weeks
This commit is contained in:
Mikolaj Golub 2012-02-19 10:38:55 +00:00
parent b6193c2409
commit 53c49998d5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=231912

View File

@ -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