-fixing #2546
[oweals/gnunet.git] / src / arm / gnunet-arm.c
index 744c3f208fb072d71e57d9c9f40ddcdefbe5234e..d84de1c7ab84bbdde405407a3494c25de5034a6a 100644 (file)
  */
 #include "platform.h"
 #include "gnunet_arm_service.h"
-#include "gnunet_client_lib.h"
 #include "gnunet_constants.h"
-#include "gnunet_getopt_lib.h"
-#include "gnunet_program_lib.h"
-#include "gnunet_time_lib.h"
+#include "gnunet_util_lib.h"
 
 /**
  * Timeout for stopping services.  Long to give some services a real chance.
@@ -129,6 +126,16 @@ static unsigned int phase;
 static struct GNUNET_TIME_Relative timeout;
 
 
+/**
+ * Do we want to give our stdout to gnunet-service-arm?
+ */
+static unsigned int no_stdout = 0;
+
+/**
+ * Do we want to give our stderr to gnunet-service-arm?
+ */
+static unsigned int no_stderr = 0;
+
 /**
  * Main continuation-passing-style loop.  Runs the various
  * jobs that we've been asked to do in order.
@@ -326,6 +333,8 @@ cps_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
          if (start)
            {
              GNUNET_ARM_start_service (h, "arm",
+                                        (no_stdout ? 0 : GNUNET_OS_INHERIT_STD_OUT) |
+                                        (no_stderr ? 0 : GNUNET_OS_INHERIT_STD_ERR),
                                        (0 ==
                                         timeout.rel_value) ? START_TIMEOUT :
                                        timeout, &confirm_cb, "arm");
@@ -336,6 +345,8 @@ cps_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
          if (init != NULL)
            {
              GNUNET_ARM_start_service (h, init,
+                                        (no_stdout ? 0 : GNUNET_OS_INHERIT_STD_OUT) |
+                                        (no_stderr ? 0 : GNUNET_OS_INHERIT_STD_ERR),
                                        (0 ==
                                         timeout.rel_value) ? START_TIMEOUT :
                                        timeout, &confirm_cb, init);
@@ -401,8 +412,6 @@ cps_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 int
 main (int argc, char *const *argv)
 {
-  static unsigned long long temp_timeout_ms;
-
   static const struct GNUNET_GETOPT_CommandLineOption options[] = {
     {'e', "end", NULL, gettext_noop ("stop all GNUnet services"),
      GNUNET_NO, &GNUNET_GETOPT_set_one, &end},
@@ -422,15 +431,16 @@ main (int argc, char *const *argv)
      GNUNET_NO, &GNUNET_GETOPT_set_one, &quiet},
     {'T', "timeout", NULL,
      gettext_noop ("timeout for completing current operation"),
-     GNUNET_YES, &GNUNET_GETOPT_set_ulong, &temp_timeout_ms},
+     GNUNET_YES, &GNUNET_GETOPT_set_relative_time, &timeout},
     {'I', "info", NULL, gettext_noop ("List currently running services"),
      GNUNET_NO, &GNUNET_GETOPT_set_one, &list},
+    {'O', "no-stdout", NULL, gettext_noop ("Don't let gnunet-service-arm inherit standard output"),
+     GNUNET_NO, &GNUNET_GETOPT_set_one, &no_stdout},
+    {'E', "no-stderr", NULL, gettext_noop ("Don't let gnunet-service-arm inherit standard error"),
+     GNUNET_NO, &GNUNET_GETOPT_set_one, &no_stderr},
     GNUNET_GETOPT_OPTION_END
   };
 
-  if (temp_timeout_ms > 0)
-    timeout.rel_value = temp_timeout_ms;
-
   if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
     return 2;