daemon: optionally call mlockall() on startup

This commit is contained in:
Lennart Poettering 2009-06-07 00:43:03 +02:00
parent 71ce195d3b
commit a9b38b3530
5 changed files with 37 additions and 12 deletions

View file

@ -40,6 +40,10 @@
#include <liboil/liboil.h>
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif
#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
@ -960,6 +964,17 @@ int main(int argc, char *argv[]) {
pa_rtsig_configure(SIGRTMIN, SIGRTMAX-1);
#endif
if (conf->lock_memory) {
#ifdef HAVE_SYS_MMAN_H
if (mlockall(MCL_FUTURE) < 0)
pa_log_warn("mlockall() failed: %s", pa_cstrerror(errno));
else
pa_log_info("Sucessfully locked process into memory.");
#else
pa_log_warn("Memory locking requested but not supported on platform.");
#endif
}
pa_memtrap_install();
pa_assert_se(mainloop = pa_mainloop_new());