From a9b38b3530318daf44d55c5fdfdd12b2299ef215 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sun, 7 Jun 2009 00:43:03 +0200 Subject: daemon: optionally call mlockall() on startup --- src/daemon/main.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/daemon/main.c') diff --git a/src/daemon/main.c b/src/daemon/main.c index 3e50baad..58f8d660 100644 --- a/src/daemon/main.c +++ b/src/daemon/main.c @@ -40,6 +40,10 @@ #include +#ifdef HAVE_SYS_MMAN_H +#include +#endif + #ifdef HAVE_SYS_IOCTL_H #include #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()); -- cgit