Sorry, we had a lack of communication down here... our dev did a change and 
didn't
change the changelog of our custom debian package...


Here is the patch he made
(against 0.1.a-4 I think)

Perhaps it's easily tune-able for 0.2

Regards,

--- restartd-0.1.a/main.c       2006-03-24 11:01:01.000000000 +0100
+++ restartd-0.1.a-2/main.c     2006-05-08 13:22:33.000000000 +0200
@@ -78,6 +78,7 @@
 
   debug = 0;
   check_interval = 20;
+  foreground = 0;
   
   // Options
   
@@ -95,6 +96,9 @@
 
     if (!strcmp(argv[i], "-d") || !strcmp(argv[i], "--debug"))
        debug = 1;
+    
+    if (!strcmp(argv[i], "-f") || !strcmp(argv[i], "--foreground"))
+       foreground = 1;
 
     if (!strcmp(argv[i], "-i") || !strcmp(argv[i], "--interval")) {
        if (atoi(argv[i + 1]) > 0) {
@@ -112,7 +116,8 @@
         printf("restartd is a GNU/GPL software.\n");
         printf("Parameters:\n");
         printf("       -c <config_file> : config file (default is 
/etc/restartd.conf)\n");
-        printf("       -d               : set debug on. (pooor)\n");
+        printf("       -d               : set debug on. (poor)\n");
+        printf("       -f               : run in foreground\n");
         printf("       -i <interval_sec>: the check interval in second\n");
         printf("       -h               : help\n\n");
      }
@@ -127,7 +132,7 @@
 
   read_config ();
 
-  syslog (LOG_INFO, "Config file has read. Found %d process to check.",
+  syslog (LOG_INFO, "Config file has been read. Found %d process to check.",
          config_process_number);
 
   procdir_dirent = malloc (sizeof (struct dirent));
@@ -142,15 +147,17 @@
 
 
   // Fork
-  if (!(child = fork ()))
+  if (foreground == 1 || !(child = fork ()))
     {
 
       // generic daemon stuff from 
http://www.aarnet.edu.au/~gdt/articles/2003-09-nowhere-daemon/daemon.html
       // added by [EMAIL PROTECTED] - 041216
-      if (setsid() == (pid_t)(-1)) {
-         fprintf (stderr, "setsid failed\n");
-         syslog (LOG_ERR, "setsid failed");
-         return -1;
+      if (!foreground) {
+             if (setsid() == (pid_t)(-1)) {
+                fprintf (stderr, "setsid failed\n");
+                syslog (LOG_ERR, "setsid failed");
+                return -1;
+             }
       }
       if ((chdir("/")) < 0) {
          syslog (LOG_ERR, "cannot chdir to /");

Reply via email to