src/rrd_daemon.c: Remove another `goto'.
authorFlorian Forster <octo@leeloo.home.verplant.org>
Sun, 14 Sep 2008 07:56:33 +0000 (09:56 +0200)
committerFlorian Forster <octo@leeloo.home.verplant.org>
Sun, 14 Sep 2008 07:56:33 +0000 (09:56 +0200)
It only looks much because some indentation has been changed.

src/rrd_daemon.c

index 0fd0fab..75e7af0 100644 (file)
@@ -1754,9 +1754,7 @@ static void *listen_thread_main (void *args __attribute__((unused))) /* {{{ */
 
 static int daemonize (void) /* {{{ */
 {
-  pid_t child;
   int status;
-  char *base_dir;
 
   /* These structures are static, because `sigaction' behaves weird if the are
    * overwritten.. */
@@ -1764,44 +1762,46 @@ static int daemonize (void) /* {{{ */
   static struct sigaction sa_term;
   static struct sigaction sa_pipe;
 
-  if (stay_foreground)
-    goto child_startup;
-
-  child = fork ();
-  if (child < 0)
+  if (!stay_foreground)
   {
-    fprintf (stderr, "daemonize: fork(2) failed.\n");
-    return (-1);
-  }
-  else if (child > 0)
-  {
-    return (1);
-  }
+    pid_t child;
+    char *base_dir;
 
-  /* Change into the /tmp directory. */
-  base_dir = (config_base_dir != NULL)
-    ? config_base_dir
-    : "/tmp";
-  status = chdir (base_dir);
-  if (status != 0)
-  {
-    fprintf (stderr, "daemonize: chdir (%s) failed.\n", base_dir);
-    return (-1);
-  }
+    child = fork ();
+    if (child < 0)
+    {
+      fprintf (stderr, "daemonize: fork(2) failed.\n");
+      return (-1);
+    }
+    else if (child > 0)
+    {
+      return (1);
+    }
+
+    /* Change into the /tmp directory. */
+    base_dir = (config_base_dir != NULL)
+      ? config_base_dir
+      : "/tmp";
+    status = chdir (base_dir);
+    if (status != 0)
+    {
+      fprintf (stderr, "daemonize: chdir (%s) failed.\n", base_dir);
+      return (-1);
+    }
 
-  /* Become session leader */
-  setsid ();
+    /* Become session leader */
+    setsid ();
 
-  /* Open the first three file descriptors to /dev/null */
-  close (2);
-  close (1);
-  close (0);
+    /* Open the first three file descriptors to /dev/null */
+    close (2);
+    close (1);
+    close (0);
 
-  open ("/dev/null", O_RDWR);
-  dup (0);
-  dup (0);
+    open ("/dev/null", O_RDWR);
+    dup (0);
+    dup (0);
+  } /* if (!stay_foreground) */
 
-child_startup:
   /* Install signal handlers */
   memset (&sa_int, 0, sizeof (sa_int));
   sa_int.sa_handler = sig_int_handler;