diff -ruw restartd-0.1.a.orig/debian/changelog restartd-0.1.a/debian/changelog
--- restartd-0.1.a.orig/debian/changelog        2002-08-12 07:21:10.000000000 -0700
+++ restartd-0.1.a/debian/changelog     2004-12-16 19:10:11.000000000 -0800
@@ -1,3 +1,9 @@
+restartd (0.1.a-3-postica-1) unstable; urgency=low
+
+  * Disassociate from controlling terminal.  Set stdin/stdout/stderr to
+    /dev/null.  Change working directory to /.  (Closes #281961, #282328)
+
+ -- Christian G. Warden <cwarden@postica.com>  Thu, 16 Dec 2004 18:23:29 -0800
 restartd (0.1.a-3) unstable; urgency=low

   * Fixed memory leak, forgot regfree(3) after regular expression. Closes: bug#155220
diff -ruw restartd-0.1.a.orig/main.c restartd-0.1.a/main.c
--- restartd-0.1.a.orig/main.c  2002-08-12 07:19:04.000000000 -0700
+++ restartd-0.1.a/main.c       2004-12-16 19:17:25.000000000 -0800
@@ -67,7 +67,7 @@
   char *proc_cmdline_str;
   ssize_t proc_cmdline_str_length;
   char *proc_cmdline_name;
-  int i;
+  int i, f;
   FILE *out_proc;
   regex_t *regc;
   size_t r_nmatch = 0;
@@ -145,6 +145,54 @@
   if (!(child = fork ()))
     {

+      // generic daemon stuff from http://www.aarnet.edu.au/~gdt/articles/2003-09-nowhere-daemon/daemon.html
+      // added by cwarden@postica.com - 041216
+      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 /");
+         return -1;
+      }
+      f = open("/dev/null", O_RDONLY);
+      if (f == -1)
+      {
+          syslog (LOG_ERR, "failed to open /dev/null");
+          return -1;
+      }
+      else
+      {
+          if (dup2(f, fileno(stdin)) == -1)
+          {
+              syslog (LOG_ERR, "failed to set stdin to /dev/null");
+              return -1;
+          }
+          (void)close(f);
+      }
+
+      f = open("/dev/null", O_WRONLY);
+      if (f == -1)
+      {
+          syslog (LOG_ERR, "failed to open /dev/null");
+          return -1;
+      }
+      else
+      {
+          if (dup2(f, fileno(stdout)) == -1)
+          {
+              syslog (LOG_ERR, "failed to set stdout to /dev/null");
+              return -1;
+          }
+          if (dup2(f, fileno(stderr)) == -1)
+          {
+              syslog (LOG_ERR, "failed to set stderr to /dev/null");
+              return -1;
+          }
+          (void)close(f);
+      }
+
       out_proc = fopen("/var/run/restartd.pid", "wt");
       fprintf(out_proc, "%d", getpid());
       fclose(out_proc);
@@ -154,7 +202,6 @@

          if ((procdir_id = opendir ("/proc")) == NULL)
            {
-             fprintf (stderr, "%s: cannot open /proc dir.\n", argv[0]);
              syslog (LOG_ERR, "cannot open /proc dir");
              return -1;
            }

