[PATCH] urxvtd and mlock
Russell Harmon
russ at eatnumber1.com
Wed Jan 21 19:44:00 CET 2009
I wrote a patch that adds a --lock option to urxvtd to call mlockall on
itself. This prevents urxvtd from ever being swapped. Patch follows:
--- src/rxvtd.C.bak 2009-01-21 09:01:22.394079003 -0500
+++ src/rxvtd.C 2009-01-21 09:21:36.534082871 -0500
@@ -32,6 +32,7 @@
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <sys/mman.h>
#include <cerrno>
@@ -216,7 +217,7 @@
return err ();
}
-int opt_fork, opt_opendisplay, opt_quiet;
+int opt_fork, opt_opendisplay, opt_quiet, opt_lock;
int
main (int argc, const char *const *argv)
@@ -231,6 +232,8 @@
opt_opendisplay = 1;
else if (!strcmp (argv [i], "-q") || !strcmp (argv [i], "--quiet"))
opt_quiet = 1;
+ else if (!strcmp (argv [i], "-l") || !strcmp (argv [i], "--lock"))
+ opt_lock = 1;
else
{
rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv
[i]);
@@ -256,10 +259,19 @@
free (sockname);
+ pid_t pid = 0;
if (opt_fork)
{
- pid_t pid = fork ();
+ pid = fork ();
+ }
+
+ // Optionally preform a mlockall so this process does not get swapped
out.
+ if (opt_lock && pid == 0)
+ if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1)
+ perror("unable to lock into ram");
+ if (opt_fork)
+ {
if (pid < 0)
{
rxvt_log ("unable to fork daemon, aborting.\n");
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.schmorp.de/pipermail/rxvt-unicode/attachments/20090121/1bfa1cdb/attachment.html>
More information about the rxvt-unicode
mailing list