ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtd.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtd.C (file contents):
Revision 1.46 by root, Sun Jun 15 13:54:15 2008 UTC vs.
Revision 1.50 by root, Fri Oct 22 05:58:00 2010 UTC

31#include <sys/types.h> 31#include <sys/types.h>
32#include <sys/stat.h> 32#include <sys/stat.h>
33#include <sys/socket.h> 33#include <sys/socket.h>
34#include <sys/un.h> 34#include <sys/un.h>
35 35
36#if defined(ENABLE_FRILLS) && defined(_POSIX_MEMLOCK) && _POSIX_MEMLOCK > 0
37# define ENABLE_MLOCK 1
38#endif
39
40#if ENABLE_MLOCK
41# include <sys/mman.h>
42#endif
43
36#include <cerrno> 44#include <cerrno>
37 45
38#include "rxvt.h" 46#include "rxvt.h"
39#include "rxvtdaemon.h" 47#include "rxvtdaemon.h"
40#include "libptytty.h" 48#include "libptytty.h"
214 } 222 }
215 else 223 else
216 return err (); 224 return err ();
217} 225}
218 226
219int opt_fork, opt_opendisplay, opt_quiet;
220
221int 227int
222main (int argc, const char *const *argv) 228main (int argc, const char *const *argv)
223{ 229{
230 int opt_fork, opt_opendisplay, opt_quiet;
231#if ENABLE_MLOCK
232 int opt_lock;
233#endif
234
224 rxvt_init (); 235 rxvt_init ();
225 236
226 for (int i = 1; i < argc; i++) 237 for (int i = 1; i < argc; i++)
227 { 238 {
228 if (!strcmp (argv [i], "-f") || !strcmp (argv [i], "--fork")) 239 if (!strcmp (argv [i], "-f") || !strcmp (argv [i], "--fork"))
229 opt_fork = 1; 240 opt_fork = 1;
230 else if (!strcmp (argv [i], "-o") || !strcmp (argv [i], "--opendisplay")) 241 else if (!strcmp (argv [i], "-o") || !strcmp (argv [i], "--opendisplay"))
231 opt_opendisplay = 1; 242 opt_opendisplay = 1;
232 else if (!strcmp (argv [i], "-q") || !strcmp (argv [i], "--quiet")) 243 else if (!strcmp (argv [i], "-q") || !strcmp (argv [i], "--quiet"))
233 opt_quiet = 1; 244 opt_quiet = 1;
245#if ENABLE_MLOCK
246 else if (!strcmp (argv [i], "-m") || !strcmp (argv [i], "--mlock"))
247 opt_lock = 1;
248#endif
234 else 249 else
235 { 250 {
236 rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]); 251 rxvt_log ("%s: unknown option '%s', aborting.\n", argv [0], argv [i]);
237 return EXIT_FAILURE; 252 return EXIT_FAILURE;
238 } 253 }
254 fflush (stdout); 269 fflush (stdout);
255 } 270 }
256 271
257 free (sockname); 272 free (sockname);
258 273
274 pid_t pid = 0;
259 if (opt_fork) 275 if (opt_fork)
260 { 276 {
261 pid_t pid = fork (); 277 pid = fork ();
278 }
262 279
280#if ENABLE_MLOCK
281 // Optionally perform an mlockall so this process does not get swapped out.
282 if (opt_lock && !pid)
283 if (mlockall (MCL_CURRENT | MCL_FUTURE) < 0)
284 perror ("unable to lock into ram");
285#endif
286
287 if (opt_fork)
288 {
263 if (pid < 0) 289 if (pid < 0)
264 { 290 {
265 rxvt_log ("unable to fork daemon, aborting.\n"); 291 rxvt_log ("unable to fork daemon, aborting.\n");
266 return EXIT_FAILURE; 292 return EXIT_FAILURE;
267 } 293 }
269 _exit (EXIT_SUCCESS); 295 _exit (EXIT_SUCCESS);
270 296
271 ev_default_fork (); 297 ev_default_fork ();
272 } 298 }
273 299
274 ev_loop (0); 300 ev_run ();
275 301
276 return EXIT_SUCCESS; 302 return EXIT_SUCCESS;
277} 303}
278 304

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines