diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-06-07 00:43:03 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-06-07 00:45:47 +0200 |
commit | a9b38b3530318daf44d55c5fdfdd12b2299ef215 (patch) | |
tree | 435279d4c92cc884863496c6de23f63190c8befa /src/daemon/main.c | |
parent | 71ce195d3bb2cc1f88210fd7e22495bc38d2f72d (diff) |
daemon: optionally call mlockall() on startup
Diffstat (limited to 'src/daemon/main.c')
-rw-r--r-- | src/daemon/main.c | 15 |
1 files changed, 15 insertions, 0 deletions
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 <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()); |