from aeriebsd. watchdogd locks itself into memory, so it's helpful to
reduce the footprint (daemon has stacksize-cur=8M by default).

root     18814  0.0  1.6   116  8372 ??  S<s    2:09PM    0:00.17 
/usr/sbin/watchdogd
root     14155  0.0  0.1   160   428 ??  S<s   Fri11PM    0:00.72 
/usr/sbin/watchdogd

tested on net5501.
ok?

Index: watchdogd.c
===================================================================
RCS file: /cvs/src/usr.sbin/watchdogd/watchdogd.c,v
retrieving revision 1.12
diff -u -p -r1.12 watchdogd.c
--- watchdogd.c 12 May 2008 19:15:02 -0000      1.12
+++ watchdogd.c 12 Jun 2009 22:32:30 -0000
@@ -52,6 +52,7 @@ sighdlr(int signum)
 int
 main(int argc, char *argv[])
 {
+       struct rlimit    rlim;
        const char      *errstr;
        size_t           len;
        u_int            interval = 0, period = 30, nperiod;
@@ -139,6 +140,14 @@ main(int argc, char *argv[])
                warn("can't daemonize, restoring original values");
                goto restore;
        }
+
+       /*
+        * mlockall() below will wire the whole stack up to the limit
+        * thus we have to reduce stack size to avoid resource abuse
+        */
+       rlim.rlim_cur = 256 * 1024;
+       rlim.rlim_max = 256 * 1024;
+       (void)setrlimit(RLIMIT_STACK, &rlim);
 
        (void)mlockall(MCL_CURRENT | MCL_FUTURE);
        setpriority(PRIO_PROCESS, getpid(), -5);

Reply via email to