*** empty log message ***
authorroot <root>
Mon, 2 Feb 2009 22:38:40 +0000 (22:38 +0000)
committerroot <root>
Mon, 2 Feb 2009 22:38:40 +0000 (22:38 +0000)
Changes
doc/rxvt.7.pod
doc/rxvtd.1.pod
src/rxvtd.C

diff --git a/Changes b/Changes
index a91a3d680225425747226b525795b9e79b4192d2..f330a443f13682598dbe502f36f7e5f17d50ac29 100644 (file)
--- a/Changes
+++ b/Changes
@@ -21,6 +21,8 @@ DUMB: support tex fonts
 
 TODO: exg-- patch
 TODO: selection_beg/end should set screen, or so
+       - enable --mlock option for urxvt with frills on
+          systems supporting it (patch by Russell Harmon).
        - urxvt did not compile without frills enabled
           (analysed by Matthew Rosewarne).
 
index ab13ecd3d7b1bb5c4aa39e0ac57bd2b378ab0b04..ea916df46b618110a7dd029a2ee3a128a6b193a9 100644 (file)
@@ -1210,6 +1210,12 @@ possibly working workaround is to use a wcwidth implementation like
 
 http://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c
 
+=head3 I want 256 colors
+
+Are you sure you need 256 colors? 88 colors should be enough for most
+purposes. If you really need more, there is an unsupported patch for
+it in the doc directory, but please do not ask for it to be applied.
+
 =head1 RXVT-UNICODE TECHNICAL REFERENCE
 
 The rest of this document describes various technical aspects of
index 60c54d3b4f427022cf89d1ab17b7d11af43b038f..d6118d5a3d490d9d7256ea4abf51b8030ab905bd 100644 (file)
@@ -4,7 +4,7 @@
 
 =head1 SYNOPSIS
 
-B<@@RXVT_NAME@@d> [-q|--quiet] [-o|--opendisplay] [-f|--fork]
+B<@@RXVT_NAME@@d> [-q|--quiet] [-o|--opendisplay] [-f|--fork] [-m|--mlock]
 
 B<@@RXVT_NAME@@d> -q -o -f    # for .xsession use
 
@@ -54,6 +54,21 @@ B<@@RXVT_NAME@@d> will be killed automatically.
 This makes B<@@RXVT_NAME@@d> fork after it has bound itself to its control
 socket.
 
+=item B<-m>, B<--mlock>
+
+This makes B<@@RXVT_NAME@@d> call mlockall(2) on itself. This locks
+B<@@RXVT_NAME@@d> in RAM and prevents it from being swapped out to disk,
+at the cost of consuming a lot more memory on most operating systems.
+
+Note: In order to use this feature, your system administrator must have set
+your user's RLIMIT_MEMLOCK to a size greater than or equal to the size of the
+B<@@RXVT_NAME@@d> binary (or to unlimited). See F</etc/security/limits.conf>.
+
+Note 2: There is a known bug in glibc (possibly fixed in 2.8 and later
+versions) where calloc returns non-zeroed memory when mlockall is in
+effect. If you experience crashes or other odd behaviour while using
+--mlock, try it without it.
+
 =back
 
 =head1 EXAMPLES
index 56428270f768b141e9afd6040d0fdfa2ebdbf753..eed9b0eedcd127683be2e47d424b16895fa29c2d 100644 (file)
 #include <sys/socket.h>
 #include <sys/un.h>
 
+#if defined(ENABLE_FRILLS) && defined(_POSIX_MEMLOCK) && _POSIX_MEMLOCK > 0
+# define ENABLE_MLOCK 1
+#endif
+
+#if ENABLE_MLOCK
+# include <sys/mman.h>
+#endif
+
 #include <cerrno>
 
 #include "rxvt.h"
@@ -217,6 +225,9 @@ void server::read_cb (ev::io &w, int revents)
 }
 
 int opt_fork, opt_opendisplay, opt_quiet;
+#if ENABLE_MLOCK
+int opt_lock;
+#endif
 
 int
 main (int argc, const char *const *argv)
@@ -231,6 +242,10 @@ main (int argc, const char *const *argv)
         opt_opendisplay = 1;
       else if (!strcmp (argv [i], "-q") || !strcmp (argv [i], "--quiet"))
         opt_quiet = 1;
+#if ENABLE_MLOCK
+      else if (!strcmp (argv [i], "-m") || !strcmp (argv [i], "--mlock"))
+        opt_lock = 1;
+#endif
       else
         {
           rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]);
@@ -256,10 +271,21 @@ main (int argc, const char *const *argv)
 
   free (sockname);
 
+  pid_t pid = 0;
   if (opt_fork)
     {
-      pid_t pid = fork ();
+      pid = fork ();
+    }
 
+#if ENABLE_MLOCK
+  // 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");
+#endif
+
+  if (opt_fork)
+    {
       if (pid < 0)
         {
           rxvt_log ("unable to fork daemon, aborting.\n");