enabling use of pipes for signal communication also on UNIX to enable future integrat...
authorChristian Grothoff <christian@grothoff.org>
Mon, 27 Feb 2012 11:00:10 +0000 (11:00 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 27 Feb 2012 11:00:10 +0000 (11:00 +0000)
72 files changed:
src/arm/arm_api.c
src/arm/do_start_process.c
src/arm/gnunet-service-arm.c
src/ats/test_ats_api_bandwidth_consumption.c
src/ats/test_ats_api_scheduling.c
src/chat/test_chat.c
src/chat/test_chat_private.c
src/core/test_core_api.c
src/core/test_core_api_reliability.c
src/core/test_core_api_send_to_self.c
src/core/test_core_api_start_only.c
src/core/test_core_defaults.conf
src/core/test_core_quota_compliance.c
src/datastore/perf_datastore_api.c
src/datastore/test_datastore_api.c
src/datastore/test_datastore_api_management.c
src/datastore/test_defaults.conf
src/dht/test_dht_api.c
src/fs/test_fs_defaults.conf
src/fs/test_fs_download.c
src/fs/test_fs_download_indexed.c
src/fs/test_fs_download_persistence.c
src/fs/test_fs_list_indexed.c
src/fs/test_fs_namespace.c
src/fs/test_fs_namespace_list_updateable.c
src/fs/test_fs_publish.c
src/fs/test_fs_publish_persistence.c
src/fs/test_fs_search.c
src/fs/test_fs_search_persistence.c
src/fs/test_fs_start_stop.c
src/fs/test_fs_unindex.c
src/fs/test_fs_unindex_persistence.c
src/hostlist/test_gnunet_daemon_hostlist.c
src/hostlist/test_gnunet_daemon_hostlist_learning.c
src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
src/hostlist/test_hostlist_defaults.conf
src/include/gnunet_disk_lib.h
src/include/gnunet_os_lib.h
src/include/platform.h
src/mesh/test_mesh_api.c
src/mesh/test_mesh_local_1.c
src/mesh/test_mesh_local_2.c
src/namestore/test_namestore_api.c
src/nat/nat.c
src/nat/nat_mini.c
src/nat/test_nat_test.c
src/nse/test_nse_api.c
src/peerinfo/test_peerinfo_api.c
src/statistics/test_statistics_api.c
src/statistics/test_statistics_api_loop.c
src/statistics/test_statistics_api_watch.c
src/stream/test_stream_local.c
src/stream/test_stream_local_halfclose.c
src/testing/test_testing_defaults.conf
src/testing/testing.c
src/testing/testing_group.c
src/transport/gnunet-transport-certificate-creation.c
src/transport/gnunet-transport-connect-running-peers.c
src/transport/gnunet-transport.c
src/transport/plugin_transport_http_server.c
src/transport/plugin_transport_wlan.c
src/transport/transport-testing.c
src/util/crypto_random.c
src/util/disk.c
src/util/helper.c
src/util/os_priority.c
src/util/scheduler.c
src/util/test_common_logging_runtime_loglevels.c
src/util/test_os_start_process.c
src/util/test_resolver_api.c
src/util/test_strings.c
src/vpn/test_gnunet_vpn.c

index 12395fea9a5facf9b64f5fb21e5a61c01f80f57d..0f4ae6a4f0bf70934b1529813cc4e9f4d7f19c16 100644 (file)
@@ -410,7 +410,8 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     {
       /* Means we are ONLY running locally */
       /* we're clearly running a test, don't daemonize */
-      proc = do_start_process (NULL, loprefix, binary, "-c", config,
+      proc = do_start_process (GNUNET_NO,
+                              NULL, loprefix, binary, "-c", config,
 #if DEBUG_ARM
                               "-L", "DEBUG",
 #endif
@@ -419,7 +420,8 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     }
   else
     {
-      proc = do_start_process (NULL, loprefix, binary, "-c", config,
+      proc = do_start_process (GNUNET_NO,
+                              NULL, loprefix, binary, "-c", config,
 #if DEBUG_ARM
                               "-L", "DEBUG",
 #endif
index fd7fc17ed7a4853790b389f34396d1c523cdff0c..865ea8e7db2f510426b0b4b8c08f820a143cc34b 100644 (file)
@@ -13,7 +13,8 @@
  * @return handle of the started process, NULL on error
  */
 static struct GNUNET_OS_Process *
-do_start_process (const SOCKTYPE * lsocks, const char *first_arg, ...)
+do_start_process (int pipe_control,
+                 const SOCKTYPE * lsocks, const char *first_arg, ...)
 {
   va_list ap;
   char **argv;
@@ -95,7 +96,7 @@ do_start_process (const SOCKTYPE * lsocks, const char *first_arg, ...)
 /* *INDENT-ON* */
   va_end (ap);
   argv[argv_size] = NULL;
-  proc = GNUNET_OS_start_process_v (lsocks, argv[0], argv);
+  proc = GNUNET_OS_start_process_v (pipe_control, lsocks, argv[0], argv);
   while (argv_size > 0)
     GNUNET_free (argv[--argv_size]);
   GNUNET_free (argv);
index 064cb9777c0af57edd2dddd4fd05e8dc60674236..f4430ed0c8e1f7f5e204d5fa3a2686f1114b1d27 100644 (file)
@@ -152,6 +152,11 @@ struct ServiceList
    */
   int is_default;
 
+  /**
+   * Should we use pipes to signal this process? (YES for Java binaries and if we
+   * are on Windoze).
+   */
+  int pipe_control;
 };
 
 /**
@@ -311,11 +316,13 @@ start_process (struct ServiceList *sl)
   GNUNET_assert (NULL == sl->proc);
   if (GNUNET_YES == use_debug)
     sl->proc =
-      do_start_process (lsocks, loprefix, sl->binary, "-c", sl->config, "-L",
+      do_start_process (sl->pipe_control,
+                       lsocks, loprefix, sl->binary, "-c", sl->config, "-L",
                        "DEBUG", options, NULL);
   else
     sl->proc =
-      do_start_process (lsocks, loprefix, sl->binary, "-c", sl->config,
+      do_start_process (sl->pipe_control,
+                       lsocks, loprefix, sl->binary, "-c", sl->config,
                        options, NULL);
   if (sl->proc == NULL)
     GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to start service `%s'\n"),
@@ -1070,6 +1077,12 @@ setup_service (void *cls, const char *section)
   sl->config = config;
   sl->backoff = GNUNET_TIME_UNIT_MILLISECONDS;
   sl->restart_at = GNUNET_TIME_UNIT_FOREVER_ABS;
+#if WINDOWS
+  sl->pipe_control = GNUNET_YES;
+#else
+  if (GNUNET_CONFIGURATION_have_value (cfg, section, "PIPECONTROL"))
+    sl->pipe_control = GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "PIPECONTROL");
+#endif  
   GNUNET_CONTAINER_DLL_insert (running_head, running_tail, sl);
   if (GNUNET_YES !=
       GNUNET_CONFIGURATION_get_value_yesno (cfg, section, "AUTOSTART"))
index 9b09f5a49d7cdccea2bdd39b6d2d1670085c5687..a84927d585fe409ef0966c839df55edea72ce7b6 100644 (file)
@@ -199,7 +199,7 @@ void
 start_arm (const char *cfgname)
 {
   arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE_ARM
                                "-L", "DEBUG",
index 9435a7b6f4e8ac054e7599f5e458f8095113d5ad..892186cd1238e1f0bcf9bbd1d63d903f343b498d 100644 (file)
@@ -156,7 +156,7 @@ void
 start_arm (const char *cfgname)
 {
   arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE_ARM
                                "-L", "DEBUG",
index 7cf8b19cf520c3cd304085f5b13c26559b142681..fec5db02a3f25e827ce94cb124596cbee9a3a9e7 100644 (file)
@@ -119,7 +119,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index acec5bcf0138859dc90cc2504c8bb5ef81d67ab9..cbc90656f169b5cfa13015085babe42f774710c1 100644 (file)
@@ -133,7 +133,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 7bf09193309894b4d2f3ab6a3cabeb49053760c4..271c2ce08cb472391eca32ec90efe8af2b1661f9 100644 (file)
@@ -319,7 +319,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 94c28fa81079fcb0fe9dca3f5f5c20479743142e..645b27e74687c7638575b43ae7682b0b5976a29d 100644 (file)
@@ -442,7 +442,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index f04f94fac7a0363acafd84bae90a3a8b642dd7e4..4fa73d9519649980f16de8c9c67a61a3fd1d5022 100644 (file)
@@ -170,7 +170,7 @@ run (void *cls, char *const *args, const char *cfgfile,
   core_cfg = GNUNET_CONFIGURATION_create ();
 
   arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 876e3b0f8bcb38a6dc336ecdd67a82ce6de6781b..2eca57512d92eefdce00990273d2fd10b2f3be43 100644 (file)
@@ -148,7 +148,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 82f14a9d9f4861517ba850e5126309935f33d088..f91ee42bb4e57e8071623440a8ec0354cbeb8956 100644 (file)
@@ -47,4 +47,7 @@ AUTOSTART = NO
 AUTOSTART = NO
 
 [dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
index f16cc544101251fe90568725400309ae2cd890d3..7c16531d82b1e80c386c8dd058d63b6d1884c618 100644 (file)
@@ -569,7 +569,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 393972da2e9a2327d49d0f93ff28d00b201123f7..aae152db81dc5e6eb33551aa86eb555f470d67f2 100644 (file)
@@ -343,7 +343,7 @@ check ()
   GNUNET_snprintf (cfg_name, sizeof (cfg_name),
                    "test_datastore_api_data_%s.conf", plugin_name);
   proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index c93f5412eedb0ca8682bc5581fa3c5d30a6e3279..25836ca663065cb6169fc0eb7b1feab0e37ffbe9 100644 (file)
@@ -526,7 +526,7 @@ check ()
                    "test_datastore_api_data_%s.conf", plugin_name);
 #if START_DATASTORE
   proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 2d5cc6bf9500d61e9736abdc9138911a1f42efdb..4015c2cb2b7cb18e2f106c290842e6716b8149a1 100644 (file)
@@ -311,7 +311,7 @@ check ()
   GNUNET_snprintf (cfg_name, sizeof (cfg_name),
                    "test_datastore_api_data_%s.conf", plugin_name);
   proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index bbc1ad190d80b2dc3a036d07787d495b83dfc987..bdba91731a02103b8e44aabf1f64759d344f1386 100644 (file)
@@ -15,4 +15,7 @@ AUTOSTART = NO
 AUTOSTART = NO
 
 [dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
index b31cd1a72198c15e4423d6ebc9fcf85defd96223..182856a8e48bbb34fc861ccd1bf314a6395082a2 100644 (file)
@@ -263,7 +263,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE_ARM
                                "-L", "DEBUG",
index 9dd7178631d404deb1825146aa2dc03d7ec5430f..e32213bc33f976e06b5c0478c7b05bbf49605379 100644 (file)
@@ -75,4 +75,7 @@ AUTOSTART = NO
 AUTOSTART = NO
 
 [dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
index 51020c4a2f6a2aa4f2ee198f2ca50368cce2e050..570eab909c9976950d967e2eee888664f7f0da6d 100644 (file)
@@ -245,7 +245,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index b9b791d1f7dc79eca5a8576fbeae080210182907..e8504f17596752b618dc4ad04738238b76d2157c 100644 (file)
@@ -246,7 +246,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index f0dc6f3a6b90e18af0ea905e7f4bb5163c7f1293..bcb1c54b66d587ac8bbeb6d79db6a30f59fa9665 100644 (file)
@@ -295,7 +295,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 5df503a65087c9778cd30212c99aedf544d3c7f8..535f8ef58fa37baa42503196447b7eec3640e96a 100644 (file)
@@ -188,7 +188,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 7ef5d89be7a1516d1e05f1d604d1121e67594f37..d25fd6f834cccc86f6065b8f3bdd9f343be6c6db 100644 (file)
@@ -67,7 +67,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 1ad2fb5ac2228193a7806e5b1bb933c9efd74913..44775ac0e0794a3531fa79a65e8295531bd9bdb6 100644 (file)
@@ -71,7 +71,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 1ae3ab451b9a8dbca6e816c702747b1fafb2010b..e52743876dd1829c4858032758b7050356f5babf 100644 (file)
@@ -173,7 +173,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 0b78282560cd0ee8d43829aed90b9f2304d9dfc2..7707eac32162bc1ed83f371b1201e2cf96ccca74 100644 (file)
@@ -236,7 +236,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index e1046153472dc1773b230bbe1b030d422e1050b8..f6c8f00f811d6edaac309aa67f6bddb62d2ee29c 100644 (file)
@@ -174,7 +174,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index bb38d92c731cd1fce5b6ba06bc312e27a701bbc1..38f88a82a08a1675da1c1ec0382cce40fb7ca2b6 100644 (file)
@@ -236,7 +236,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index c65ad2fc19fc5a0e2d8e64edd5d5655a281dbe91..0ef0723f957ef63943949d206b9657429ca83dfe 100644 (file)
@@ -57,7 +57,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index cede0f5b716578dddaaac6d38334548b08bfcd8e..a8b68a3cf1df633c438b0c83f3e64ed29b3ee7fa 100644 (file)
@@ -187,7 +187,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index b13378f20a78fc15375517c5172610365cb9bcc5..575e1715fd6b991446e608114ff5b6733e264075 100644 (file)
@@ -249,7 +249,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 056e5617766fb8b0487e57c996e243b6f6f7288f..da3ab8b58f417ab38ce3009cb9f4878f0acfd7c5 100644 (file)
@@ -140,7 +140,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index b2771067763fe85a4518bd390350759e79382467..9ef8812f6a2fb1a8aa09cdb57910129627f17af3 100644 (file)
@@ -370,7 +370,7 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
@@ -406,7 +406,7 @@ setup_adv_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index e347673d8a49c23659f6fcf98d7b07a5b245836d..a9915574bb8a860daa01e57408f7191cb97a5e38 100644 (file)
@@ -144,7 +144,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",
index 08c58b963ed2b4d64848537e1eb6fb7205d40886..b74a6a615dbf16ab3cc9cfd492acff9c97ad73ab 100644 (file)
@@ -50,4 +50,7 @@ AUTOSTART = NO
 AUTOSTART = NO
 
 [dv]
-AUTOSTART = NO
\ No newline at end of file
+AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
index 9c88a163bf38651fece825018d1a20ac1fe12b4c..18f553576d86595e19b4a572ddc3cfd2ee44d25c 100644 (file)
 #define OFF_T off_t
 #endif
 
-/**
- * Opaque handle used to access files.
- */
-struct GNUNET_DISK_FileHandle;
-
 /**
  * Handle used to manage a pipe.
  */
@@ -759,36 +754,6 @@ GNUNET_DISK_file_unmap (struct GNUNET_DISK_MapHandle *h);
 int
 GNUNET_DISK_file_sync (const struct GNUNET_DISK_FileHandle *h);
 
-/**
- * Creates a named pipe/FIFO and opens it
- * @param fn pointer to the name of the named pipe or to NULL
- * @param flags open flags
- * @param perm access permissions
- * @return pipe handle on success, NULL on error
- */
-struct GNUNET_DISK_FileHandle *
-GNUNET_DISK_npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags,
-                          enum GNUNET_DISK_AccessPermissions perm);
-
-/**
- * Opens already existing named pipe/FIFO
- *
- * @param fn name of an existing named pipe
- * @param flags open flags
- * @param perm access permissions
- * @return pipe handle on success, NULL on error
- */
-struct GNUNET_DISK_FileHandle *
-GNUNET_DISK_npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
-                        enum GNUNET_DISK_AccessPermissions perm);
-
-/**
- * Closes a named pipe/FIFO
- * @param pipe named pipe
- * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
- */
-int
-GNUNET_DISK_npipe_close (struct GNUNET_DISK_FileHandle *pipe);
 
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
index c56947431e49889afa1e2c71bd3f4c105f531879..e9e484f785f758eabb5aa9e2d38361ebccdf5859 100644 (file)
  * @author Ioana Patrascu
  * @author Tzvetan Horozov
  * @author Milan
+ *
+ * This code manages child processes.  We can communicate with child
+ * processes using signals.  Because signals are not supported on W32
+ * and Java (at least not nicely), we can alternatively use a pipe
+ * to send signals to the child processes (if the child process is
+ * a full-blown GNUnet process that supports reading signals from 
+ * a pipe, of course).  Naturally, this also only works for 'normal'
+ * termination via signals, and not as a replacement for SIGKILL.
+ * Thus using pipes to communicate signals should only be enabled if
+ * the child is a Java process OR if we are on Windoze.
  */
 
 #ifndef GNUNET_OS_LIB_H
@@ -201,7 +211,7 @@ GNUNET_OS_process_current (void);
 
 
 /**
- * Sends sig to the process
+ * Sends a signal to the process
  *
  * @param proc pointer to process structure
  * @param sig signal
@@ -219,6 +229,7 @@ GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig);
 void
 GNUNET_OS_process_close (struct GNUNET_OS_Process *proc);
 
+
 /**
  * Get the pid of the process in question
  *
@@ -229,6 +240,7 @@ GNUNET_OS_process_close (struct GNUNET_OS_Process *proc);
 pid_t
 GNUNET_OS_process_get_pid (struct GNUNET_OS_Process *proc);
 
+
 /**
  * Set process priority
  *
@@ -241,10 +253,10 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc,
                                 enum GNUNET_SCHEDULER_Priority prio);
 
 
-
 /**
  * Start a process.
  *
+ * @param pipe_control should a pipe be used to send signals to the child?
  * @param pipe_stdin pipe to use to send input to child process (or NULL)
  * @param pipe_stdout pipe to use to get output from child process (or NULL)
  * @param filename name of the binary
@@ -252,7 +264,8 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc,
  * @return pointer to process structure of the new process, NULL on error
  */
 struct GNUNET_OS_Process *
-GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process_vap (int pipe_control,
+                            struct GNUNET_DISK_PipeHandle *pipe_stdin,
                             struct GNUNET_DISK_PipeHandle *pipe_stdout,
                             const char *filename, 
                             char *const argv[]);
@@ -261,6 +274,7 @@ GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
 /**
  * Start a process.
  *
+ * @param pipe_control should a pipe be used to send signals to the child?
  * @param pipe_stdin pipe to use to send input to child process (or NULL)
  * @param pipe_stdout pipe to use to get output from child process (or NULL)
  * @param filename name of the binary
@@ -268,7 +282,8 @@ GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
  * @return pointer to process structure of the new process, NULL on error
  */
 struct GNUNET_OS_Process *
-GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process (int pipe_control,
+                        struct GNUNET_DISK_PipeHandle *pipe_stdin,
                          struct GNUNET_DISK_PipeHandle *pipe_stdout,
                          const char *filename, ...);
 
@@ -276,6 +291,7 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
 /**
  * Start a process.
  *
+ * @param pipe_control should a pipe be used to send signals to the child?
  * @param pipe_stdin pipe to use to send input to child process (or NULL)
  * @param pipe_stdout pipe to use to get output from child process (or NULL)
  * @param filename name of the binary
@@ -283,13 +299,15 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
  * @return pointer to process structure of the new process, NULL on error
  */
 struct GNUNET_OS_Process *
-GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process_va (int pipe_control,
+                           struct GNUNET_DISK_PipeHandle *pipe_stdin,
                             struct GNUNET_DISK_PipeHandle *pipe_stdout,
                             const char *filename, va_list va);
 
 /**
  * Start a process.
  *
+ * @param pipe_control should a pipe be used to send signals to the child?
  * @param lsocks array of listen sockets to dup systemd-style (or NULL);
  *         must be NULL on platforms where dup is not supported
  * @param filename name of the binary
@@ -298,7 +316,9 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
  * @return pointer to process structure of the new process, NULL on error
  */
 struct GNUNET_OS_Process *
-GNUNET_OS_start_process_v (const SOCKTYPE *lsocks, const char *filename,
+GNUNET_OS_start_process_v (int pipe_control,
+                          const SOCKTYPE *lsocks, 
+                          const char *filename,
                            char *const argv[]);
 
 
@@ -307,6 +327,7 @@ GNUNET_OS_start_process_v (const SOCKTYPE *lsocks, const char *filename,
  */
 struct GNUNET_OS_CommandHandle;
 
+
 /**
  * Type of a function to process a line of output.
  *
@@ -315,6 +336,7 @@ struct GNUNET_OS_CommandHandle;
  */
 typedef void (*GNUNET_OS_LineProcessor) (void *cls, const char *line);
 
+
 /**
  * Stop/kill a command.
  *
@@ -370,7 +392,13 @@ GNUNET_OS_process_wait (struct GNUNET_OS_Process *proc);
 
 
 /**
- * Connects this process to its parent via pipe
+ * Connects this process to its parent via pipe;
+ * essentially, the parent control handler will read signal numbers
+ * from the 'GNUNET_OS_CONTROL_PIPE' (as given in an environment
+ * variable) and raise those signals.
+ *
+ * @param cls closure (unused)
+ * @param tc scheduler context (unused)
  */
 void
 GNUNET_OS_install_parent_control_handler (void *cls,
index 1795037313fdc292728f68bf4197b4551b762d63..7383e48ad179a5813a7d6782abd0d839e82605fe 100644 (file)
 #include <stdarg.h>
 #include <errno.h>
 #include <signal.h>
+#include <libgen.h>
 #ifdef WINDOWS
 #include <malloc.h>             /* for alloca(), on other OSes it's in stdlib.h */
 #endif
index d92c2593807fd0837578b3fd9fc76fd01408d94e..fbc1fbaff055b921a13ba3e678f641ac6b632d4e 100644 (file)
@@ -139,7 +139,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 #endif
                     NULL);
   arm_pid =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE_ARM
                                "-L", "DEBUG",
index da65b36c4a2fe37916e0796280bd6c5c7c96155a..73e2bdc13cb84da533ca1d5430fa33ab34c72a29 100644 (file)
@@ -300,7 +300,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 #endif
                     NULL);
   arm_pid =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE_ARM
                                "-L", "DEBUG",
index eff15046f5b84be13768f48262e299613a6d787e..b185f1b840c13848d2a362a181cd5fd0296a9a24 100644 (file)
@@ -293,7 +293,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 #endif
                     NULL);
   arm_pid =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE_ARM
                                "-L", "DEBUG",
index 3fd84d20fc598b64f44470b60db66a15cfa0e1ad..62cfa808a30bd5ac03d51f7336ec13281eb967d0 100644 (file)
@@ -40,7 +40,7 @@ static int res;
 static void
 start_arm (const char *cfgname)
 {
-  arm = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+  arm = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm", "-c", cfgname,
 #if VERBOSE_PEERS
                                "-L", "DEBUG",
index 02ff7547b6fcd0ceb1bda78d2f6bf15b11d3f616..744583f3d33384cf0ed88b08438d49c12a05da4c 100644 (file)
@@ -843,7 +843,7 @@ start_gnunet_nat_server (struct GNUNET_NAT_Handle *h)
 #endif
     /* Start the server process */
     h->server_proc =
-        GNUNET_OS_start_process (NULL, h->server_stdout,
+        GNUNET_OS_start_process (GNUNET_NO, NULL, h->server_stdout,
                                  "gnunet-helper-nat-server",
                                  "gnunet-helper-nat-server",
                                  h->internal_address, NULL);
@@ -1342,7 +1342,8 @@ GNUNET_NAT_run_client (struct GNUNET_NAT_Handle *h,
        inet4, (unsigned int) h->adv_port);
 #endif
   proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-helper-nat-client",
+      GNUNET_OS_start_process (GNUNET_NO,
+                              NULL, NULL, "gnunet-helper-nat-client",
                                "gnunet-helper-nat-client", h->internal_address,
                                inet4, port_as_string, NULL);
   if (NULL == proc)
index 6c48f28fec775e7fbfa06e5723e357bc6b68cd3b..830fdfd5027fe493daa4578fbef2abd74d8ab711 100644 (file)
@@ -176,7 +176,7 @@ GNUNET_NAT_mini_get_external_ipv4 (struct GNUNET_TIME_Relative timeout,
     return NULL;
   }
   eh->eip =
-      GNUNET_OS_start_process (NULL, eh->opipe, "external-ip", "external-ip",
+    GNUNET_OS_start_process (GNUNET_NO, NULL, eh->opipe, "external-ip", "external-ip",
                                NULL);
   if (NULL == eh->eip)
   {
index 2b9ef0f7cc04d05e937c2210b9c4c09d51292e4e..64617880aae5dbe4529f6a287b12003d5a37da7a 100644 (file)
@@ -118,7 +118,7 @@ main (int argc, char *const argv[])
   }
 
   gns =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-nat-server",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-nat-server",
                                "gnunet-nat-server",
 #if VERBOSE
                                "-L", "DEBUG",
index 7e0ab0bbc25ad6d8df46aca45e2ecf2986294ea6..f6cde3fe40b1f3d52f0d33c022cdce5c05778e0b 100644 (file)
@@ -110,7 +110,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE_ARM
                                "-L", "DEBUG",
index fbd12c3873647dc3951b4ac30acc5ab51135e12c..71da46be4e9e6dff6164c6b7a010c5bead8cab91 100644 (file)
@@ -179,7 +179,7 @@ check ()
     GNUNET_GETOPT_OPTION_END
   };
   proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-peerinfo",
                                "gnunet-service-peerinfo",
 #if DEBUG_PEERINFO
                                "-L", "DEBUG",
index efaf2d2ee93ef3b1f94276e6fde3fe4bd7e02e30..0647a4942d65fff3eb0e39d0a0c764392e14085c 100644 (file)
@@ -144,7 +144,7 @@ check ()
   struct GNUNET_OS_Process *proc;
 
   proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics",
                                "gnunet-service-statistics",
 #if DEBUG_STATISTICS
                                "-L", "DEBUG",
@@ -170,7 +170,7 @@ check ()
 #if START_SERVICE
   /* restart to check persistence! */
   proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics",
                                "gnunet-service-statistics",
 #if DEBUG_STATISTICS
                                "-L", "DEBUG",
index eb739b752fc73b8a568169d6ccc42b144fc28b31..32b176caa90d90ff59bcd42e0e11e243b0cab249 100644 (file)
@@ -97,7 +97,7 @@ check ()
   struct GNUNET_OS_Process *proc;
 
   proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics",
                                "gnunet-service-statistics",
 #if DEBUG_STATISTICS
                                "-L", "DEBUG",
index a70b8b311985bf36fdc847b73dfff217938233b5..979b5610eecfdfc34f9fb1930eaa3d2ebee54b3c 100644 (file)
@@ -127,7 +127,7 @@ check ()
   struct GNUNET_OS_Process *proc;
 
   proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+    GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-statistics",
                                "gnunet-service-statistics",
 #if VERBOSE
                                "-L", "DEBUG",
index 63347d826e61cadbe5a1dcbe1f000adfc2f1e6b5..4da1258fc1b4759b39f1adb536d4fd562f87b9ee 100644 (file)
@@ -331,7 +331,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 #endif
                     NULL);
    arm_pid =
-     GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+     GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                               "gnunet-service-arm",
 #if VERBOSE_ARM
                               "-L", "DEBUG",
index 5acaf213a726885c864c03da41e7a85b1d10d444..61e531ae81b17cdcf28c376ab46a1276a8b5592d 100644 (file)
@@ -327,7 +327,7 @@ run (void *cls, char *const *args, const char *cfgfile,
 #endif
                     NULL);
    arm_pid =
-     GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+     GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                               "gnunet-service-arm",
 #if VERBOSE_ARM
                               "-L", "DEBUG",
index c4810c303234bc96fd4b9e5fe9e876d2728c5119..36a4f76ea7c4bc8ba32e0892bfafe3400f92ab03 100644 (file)
@@ -61,3 +61,6 @@ AUTOSTART = NO
 
 [dv]
 AUTOSTART = NO
+
+[chat]
+AUTOSTART = NO
index 70da138a7eb36fc83829162320c3a829283a2070..16cee9037203ae88d5ab669cabed9ee97f5167a6 100644 (file)
@@ -97,11 +97,9 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
                                   GNUNET_NO, &test_address, &empty);
   if (GNUNET_YES == empty)
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Skipping empty HELLO address of peer %s\n",
                 GNUNET_i2s (&daemon->id));
-#endif
     return;
   }
 #endif
@@ -113,11 +111,9 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
 
   if (daemon->server != NULL)
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Received `%s' from transport service of `%4s', disconnecting core!\n",
                 "HELLO", GNUNET_i2s (&daemon->id));
-#endif
     GNUNET_CORE_disconnect (daemon->server);
     daemon->server = NULL;
   }
@@ -135,12 +131,9 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message)
     GNUNET_TRANSPORT_get_hello_cancel (daemon->ghh);
     daemon->ghh = NULL;
   }
-#if DEBUG_TESTING
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received `%s' from transport service of `%4s'\n", "HELLO",
               GNUNET_i2s (&daemon->id));
-#endif
-
   GNUNET_free_non_null (daemon->hello);
   daemon->hello = GNUNET_malloc (msize);
   memcpy (daemon->hello, message, msize);
@@ -192,11 +185,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   char *dst;
   int bytes_read;
 
-#if DEBUG_TESTING
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer %s FSM is in phase %u.\n",
               GNUNET_i2s (&d->id), d->phase);
-#endif
-
   d->task = GNUNET_SCHEDULER_NO_TASK;
   switch (d->phase)
   {
@@ -229,10 +219,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       return;
     }
     GNUNET_OS_process_close (d->proc);
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Successfully copied configuration file.\n");
-#endif
     d->phase = SP_COPIED;
     /* fall-through */
   case SP_COPIED:
@@ -254,14 +242,12 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       }
       if (NULL == d->hostname)
       {
-#if DEBUG_TESTING
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                     "Starting `%s', with command `%s %s %s %s'.\n",
                     "gnunet-peerinfo", "gnunet-peerinfo", "-c", d->cfgfile,
                     "-sq");
-#endif
         d->proc =
-            GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo",
+           GNUNET_OS_start_process (GNUNET_YES, NULL, d->pipe_stdout, "gnunet-peerinfo",
                                      "gnunet-peerinfo", "-c", d->cfgfile, "-sq",
                                      NULL);
         GNUNET_DISK_pipe_close_end (d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE);
@@ -273,15 +259,13 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
         else
           dst = GNUNET_strdup (d->hostname);
 
-#if DEBUG_TESTING
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                     "Starting `%s', with command `%s %s %s %s %s %s'.\n",
                     "gnunet-peerinfo", "ssh", dst, "gnunet-peerinfo", "-c",
                     d->cfgfile, "-sq");
-#endif
         if (d->ssh_port_str == NULL)
         {
-          d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", "ssh",
+          d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, d->pipe_stdout, "ssh", "ssh",
 #if !DEBUG_TESTING
                                              "-q",
 #endif
@@ -291,7 +275,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
         else
         {
           d->proc =
-              GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", "ssh", "-p",
+             GNUNET_OS_start_process (GNUNET_NO, NULL, d->pipe_stdout, "ssh", "ssh", "-p",
                                        d->ssh_port_str,
 #if !DEBUG_TESTING
                                        "-q",
@@ -317,10 +301,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
         GNUNET_DISK_pipe_close (d->pipe_stdout);
         return;
       }
-#if DEBUG_TESTING
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Started `%s', waiting for hostkey.\n", "gnunet-peerinfo");
-#endif
       d->phase = SP_HOSTKEY_CREATE;
       d->task =
           GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_absolute_get_remaining
@@ -410,9 +392,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     {
       d->phase = SP_TOPOLOGY_SETUP;
     }
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully got hostkey!\n");
-#endif
     /* Fall through */
   case SP_HOSTKEY_CREATED:
     /* wait for topology finished */
@@ -435,18 +415,14 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     /* start GNUnet on remote host */
     if (NULL == d->hostname)
     {
-#if DEBUG_TESTING
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Starting `%s', with command `%s %s %s %s %s %s'.\n",
                   "gnunet-arm", "gnunet-arm", "-c", d->cfgfile, "-L", "DEBUG",
                   "-s");
-#endif
       d->proc =
-          GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm", "-c",
+         GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm", "-c",
                                    d->cfgfile,
-#if DEBUG_TESTING
                                    "-L", "DEBUG",
-#endif
                                    "-s", "-q", "-T",
                                    GNUNET_TIME_relative_to_string
                                    (GNUNET_TIME_absolute_get_remaining
@@ -459,15 +435,13 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       else
         dst = GNUNET_strdup (d->hostname);
 
-#if DEBUG_TESTING
       GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
                   "Starting `%s', with command `%s %s %s %s %s %s %s %s'.\n",
                   "gnunet-arm", "ssh", dst, "gnunet-arm", "-c", d->cfgfile,
                   "-L", "DEBUG", "-s", "-q");
-#endif
       if (d->ssh_port_str == NULL)
       {
-        d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+        d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
 #if !DEBUG_TESTING
                                            "-q",
 #endif
@@ -484,7 +458,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       {
 
         d->proc =
-            GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-p",
+           GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-p",
                                      d->ssh_port_str,
 #if !DEBUG_TESTING
                                      "-q",
@@ -514,11 +488,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
             _("Failed to start `ssh' process.\n"));
       return;
     }
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Started `%s', waiting for `%s' to be up.\n", "gnunet-arm",
                 "gnunet-service-core");
-#endif
     d->phase = SP_START_ARMING;
     d->task =
         GNUNET_SCHEDULER_add_delayed (GNUNET_CONSTANTS_EXEC_WAIT, &start_fsm,
@@ -561,15 +533,11 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                                         d);
       return;
     }
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Successfully started `%s'.\n",
                 "gnunet-arm");
-#endif
     GNUNET_free (d->proc);
     d->phase = SP_START_CORE;
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Calling CORE_connect\n");
-#endif
     /* Fall through */
   case SP_START_CORE:
     if (d->server != NULL)
@@ -588,12 +556,9 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                _("Failed to connect to transport service!\n"));
       return;
     }
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Connected to transport service `%s', getting HELLO\n",
                 GNUNET_i2s (&d->id));
-#endif
-
     d->ghh = GNUNET_TRANSPORT_get_hello (d->th, &process_hello, d);
     /* FIXME: store task ID somewhere! */
     GNUNET_SCHEDULER_add_now (&notify_daemon_started, d);
@@ -669,9 +634,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       return;
     }
 #endif
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service startup complete!\n");
-#endif
     cb = d->cb;
     d->cb = NULL;
     d->phase = SP_START_DONE;
@@ -706,9 +669,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       return;
     }
 #endif
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service shutdown complete.\n");
-#endif
     if (NULL != d->dead_cb)
       d->dead_cb (d->dead_cb_cls, NULL);
     break;
@@ -784,9 +745,7 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
       GNUNET_free (d);
       return;
     }
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Peer shutdown complete.\n");
-#endif
     if (d->server != NULL)
     {
       GNUNET_CORE_disconnect (d->server);
@@ -849,10 +808,8 @@ start_fsm (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
         d->update_cb (d->update_cb_cls, _("`scp' did not complete cleanly.\n"));
       return;
     }
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Successfully copied configuration file.\n");
-#endif
     if (NULL != d->update_cb)
       d->update_cb (d->update_cb_cls, NULL);
     d->phase = SP_START_DONE;
@@ -937,18 +894,15 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d,
   /* Check if this is a local or remote process */
   if (NULL != d->hostname)
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Starting gnunet-arm with config `%s' on host `%s'.\n",
                 d->cfgfile, d->hostname);
-#endif
-
     if (d->username != NULL)
       GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
     else
       arg = GNUNET_strdup (d->hostname);
 
-    d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+    d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
 #if !DEBUG_TESTING
                                        "-q",
 #endif
@@ -967,11 +921,9 @@ GNUNET_TESTING_daemon_start_stopped_service (struct GNUNET_TESTING_Daemon *d,
   }
   else
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Starting gnunet-arm with config `%s' locally.\n", d->cfgfile);
-#endif
-    d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
+    d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm",
 #if DEBUG_TESTING
                                        "-L", "DEBUG",
 #endif
@@ -1010,29 +962,23 @@ GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d,
   GNUNET_assert (d->running == GNUNET_YES);
   GNUNET_assert (d->phase == SP_START_DONE);
 
-#if DEBUG_TESTING
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               _("Starting service %s for peer `%4s'\n"), service,
               GNUNET_i2s (&d->id));
-#endif
-
   d->phase = SP_SERVICE_START;
   d->max_timeout = GNUNET_TIME_relative_to_absolute (timeout);
   /* Check if this is a local or remote process */
   if (NULL != d->hostname)
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Starting gnunet-arm with config `%s' on host `%s'.\n",
                 d->cfgfile, d->hostname);
-#endif
-
     if (d->username != NULL)
       GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
     else
       arg = GNUNET_strdup (d->hostname);
 
-    d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+    d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
 #if !DEBUG_TESTING
                                        "-q",
 #endif
@@ -1052,11 +998,9 @@ GNUNET_TESTING_daemon_start_service (struct GNUNET_TESTING_Daemon *d,
   }
   else
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Starting gnunet-arm with config `%s' locally.\n", d->cfgfile);
-#endif
-    d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
+    d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm",
 #if DEBUG_TESTING
                                        "-L", "DEBUG",
 #endif
@@ -1169,10 +1113,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
   GNUNET_asprintf (&temp_file_name, "%s/gnunet-testing-config", servicehome);
   ret->cfgfile = GNUNET_DISK_mktemp (temp_file_name);
   GNUNET_free (temp_file_name);
-#if DEBUG_TESTING
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Setting up peer with configuration file `%s'.\n", ret->cfgfile);
-#endif
   if (NULL == ret->cfgfile)
   {
     GNUNET_free_non_null (ret->ssh_port_str);
@@ -1249,10 +1191,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
     /* copy directory to remote host */
     if (NULL != hostname)
     {
-#if DEBUG_TESTING
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   "Copying configuration directory to host `%s'.\n", hostname);
-#endif
       baseservicehome = GNUNET_strdup (servicehome);
       /* Remove trailing /'s */
       while (baseservicehome[strlen (baseservicehome) - 1] == '/')
@@ -1270,21 +1210,19 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
       GNUNET_free (baseservicehome);
       if (ret->ssh_port_str == NULL)
       {
-        ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", "-r",
+        ret->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", "-r",
 #if !DEBUG_TESTING
                                              "-q",
 #endif
                                              servicehome, arg, NULL);
-#if DEBUG_TESTING
         GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                     "copying directory with command scp -r %s %s\n",
                     servicehome, arg);
-#endif
       }
       else
       {
         ret->proc =
-            GNUNET_OS_start_process (NULL, NULL, "scp", "scp", "-r", "-P",
+           GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", "-r", "-P",
                                      ret->ssh_port_str,
 #if !DEBUG_TESTING
                                      "-q",
@@ -1322,10 +1260,8 @@ GNUNET_TESTING_daemon_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
       GNUNET_free (servicehome);
       return ret;
     }
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "No need to copy configuration file since we are running locally.\n");
-#endif
     ret->phase = SP_COPIED;
     /* FIXME: why add_cont? */
     GNUNET_SCHEDULER_add_continuation (&start_fsm, ret,
@@ -1383,28 +1319,22 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
   /* state clean up and notifications */
   GNUNET_free_non_null (d->hello);
 
-#if DEBUG_TESTING
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
               GNUNET_i2s (&d->id));
-#endif
-
   d->phase = SP_START_ARMING;
 
   /* Check if this is a local or remote process */
   if (NULL != d->hostname)
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Stopping gnunet-arm with config `%s' on host `%s'.\n",
                 d->cfgfile, d->hostname);
-#endif
-
     if (d->username != NULL)
       GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
     else
       arg = GNUNET_strdup (d->hostname);
 
-    d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+    d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
 #if !DEBUG_TESTING
                                        "-q",
 #endif
@@ -1419,11 +1349,9 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
   }
   else
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
-#endif
-    d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
+    d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm",
 #if DEBUG_TESTING
                                        "-L", "DEBUG",
 #endif
@@ -1466,10 +1394,8 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d,
     d->phase = SP_START_DONE;
   }
 
-#if DEBUG_TESTING
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
               GNUNET_i2s (&d->id));
-#endif
   if (d->churned_services != NULL)
   {
     d->dead_cb (d->dead_cb_cls, "A service has already been turned off!!");
@@ -1481,18 +1407,15 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d,
   /* Check if this is a local or remote process */
   if (NULL != d->hostname)
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Stopping gnunet-arm with config `%s' on host `%s'.\n",
                 d->cfgfile, d->hostname);
-#endif
-
     if (d->username != NULL)
       GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
     else
       arg = GNUNET_strdup (d->hostname);
 
-    d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+    d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
 #if !DEBUG_TESTING
                                        "-q",
 #endif
@@ -1511,11 +1434,9 @@ GNUNET_TESTING_daemon_stop_service (struct GNUNET_TESTING_Daemon *d,
   }
   else
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
-#endif
-    d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
+    d->proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-arm", "gnunet-arm",
 #if DEBUG_TESTING
                                        "-L", "DEBUG",
 #endif
@@ -1556,10 +1477,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
 
   if (NULL != d->cb)
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Setting d->dead on peer `%4s'\n"),
                 GNUNET_i2s (&d->id));
-#endif
     d->dead = GNUNET_YES;
     return;
   }
@@ -1604,10 +1523,8 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
     }
     */
   /* shutdown ARM process (will terminate others) */
-#if DEBUG_TESTING
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Terminating peer `%4s'\n"),
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Terminating peer `%4s'\n" ,
               GNUNET_i2s (&d->id));
-#endif
   d->phase = SP_SHUTDOWN_START;
   d->running = GNUNET_NO;
   if (allow_restart == GNUNET_YES)
@@ -1622,18 +1539,15 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
   /* Check if this is a local or remote process */
   if (NULL != d->hostname)
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Stopping gnunet-arm with config `%s' on host `%s'.\n",
                 d->cfgfile, d->hostname);
-#endif
-
     if (d->username != NULL)
       GNUNET_asprintf (&arg, "%s@%s", d->username, d->hostname);
     else
       arg = GNUNET_strdup (d->hostname);
 
-    d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+    d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh",
 #if !DEBUG_TESTING
                                        "-q",
 #endif
@@ -1652,11 +1566,9 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
   }
   else
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
-#endif
-    d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", "gnunet-arm",
+    d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "gnunet-arm", "gnunet-arm",
 #if DEBUG_TESTING
                                        "-L", "DEBUG",
 #endif
@@ -1715,17 +1627,15 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
       cb (cb_cls, NULL);
     return;
   }
-#if DEBUG_TESTING
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Copying updated configuration file to remote host `%s'.\n",
               d->hostname);
-#endif
   d->phase = SP_CONFIG_UPDATE;
   if (NULL != d->username)
     GNUNET_asprintf (&arg, "%s@%s:%s", d->username, d->hostname, d->cfgfile);
   else
     GNUNET_asprintf (&arg, "%s:%s", d->hostname, d->cfgfile);
-  d->proc = GNUNET_OS_start_process (NULL, NULL, "scp", "scp",
+  d->proc = GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp",
 #if !DEBUG_TESTING
                                      "-q",
 #endif
@@ -1915,11 +1825,8 @@ connect_notify (void *cls, const struct GNUNET_PeerIdentity *peer,
 {
   struct GNUNET_TESTING_ConnectContext *ctx = cls;
 
-#if DEBUG_TESTING
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Connected peer %s to peer %s\n",
               ctx->d1->shortname, GNUNET_i2s (peer));
-#endif
-
   if (0 != memcmp (&ctx->d2->id, peer, sizeof (struct GNUNET_PeerIdentity)))
     return;
   ctx->connected = GNUNET_YES;
@@ -1949,18 +1856,14 @@ send_hello (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   {
     hello = GNUNET_HELLO_get_header (ctx->d2->hello);
     GNUNET_assert (hello != NULL);
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Offering hello of %s to %s\n",
                 ctx->d2->shortname, ctx->d1->shortname);
-#endif
     GNUNET_TRANSPORT_offer_hello (ctx->d1th, hello, NULL, NULL);
     GNUNET_assert (ctx->d1core != NULL);
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Sending connect request to TRANSPORT of %s for peer %s\n",
                 GNUNET_i2s (&ctx->d1->id),
                 GNUNET_h2s (&ctx->d2->id.hashPubKey));
-#endif
     GNUNET_TRANSPORT_try_connect (ctx->d1th, &ctx->d2->id);
     ctx->timeout_hello =
         GNUNET_TIME_relative_add (ctx->timeout_hello,
@@ -1989,13 +1892,10 @@ core_init_notify (void *cls, struct GNUNET_CORE_Handle *server,
   if (connect_ctx->send_hello == GNUNET_NO)
   {
     GNUNET_TRANSPORT_try_connect (connect_ctx->d1th, &connect_ctx->d2->id);
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Sending connect request to TRANSPORT of %s for peer %s\n",
                 connect_ctx->d1->shortname, connect_ctx->d2->shortname);
-#endif
   }
-
 }
 
 
@@ -2015,11 +1915,9 @@ reattempt_daemons_connect (void *cls,
   ctx->timeout_task = GNUNET_SCHEDULER_NO_TASK;
   if ((tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) != 0)
     return;
-#if DEBUG_TESTING_RECONNECT
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "re-attempting connect of peer %s to peer %s\n",
               ctx->d1->shortname, ctx->d2->shortname);
-#endif
   ctx->connect_attempts--;
   GNUNET_assert (ctx->d1core == NULL);
   ctx->d1core_ready = GNUNET_NO;
@@ -2040,10 +1938,8 @@ reattempt_daemons_connect (void *cls,
   /* Don't know reason for initial connect failure, update the HELLO for the second peer */
   if (NULL != ctx->d2->hello)
   {
-#if DEBUG_TESTING_RECONNECT
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "updating %s's HELLO\n",
                 ctx->d2->shortname);
-#endif
     GNUNET_free (ctx->d2->hello);
     ctx->d2->hello = NULL;
     if (NULL != ctx->d2->th)
@@ -2059,21 +1955,17 @@ reattempt_daemons_connect (void *cls,
     ctx->d2->ghh =
         GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
   }
-#if DEBUG_TESTING_RECONNECT
   else
   {
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "didn't have %s's HELLO\n",
                 ctx->d2->shortname);
   }
-#endif
 
   if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL))
   {
-#if DEBUG_TESTING_RECONNECT
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "didn't have %s's HELLO, trying to get it now\n",
                 ctx->d2->shortname);
-#endif
     ctx->d2->th =
         GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL,
                                   NULL);
@@ -2090,7 +1982,6 @@ reattempt_daemons_connect (void *cls,
     ctx->d2->ghh =
         GNUNET_TRANSPORT_get_hello (ctx->d2->th, &process_hello, ctx->d2);
   }
-#if DEBUG_TESTING_RECONNECT
   else
   {
     if (NULL == ctx->d2->hello)
@@ -2100,14 +1991,11 @@ reattempt_daemons_connect (void *cls,
                   ctx->d2->shortname);
     }
   }
-#endif
 
   if (ctx->send_hello == GNUNET_YES)
   {
-#if DEBUG_TESTING_RECONNECT
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending %s's HELLO to %s\n",
                 ctx->d1->shortname, ctx->d2->shortname);
-#endif
     ctx->d1th =
         GNUNET_TRANSPORT_connect (ctx->d1->cfg, &ctx->d1->id, ctx->d1, NULL,
                                   NULL, NULL);
@@ -2126,10 +2014,8 @@ reattempt_daemons_connect (void *cls,
   }
   else
   {
-#if DEBUG_TESTING_RECONNECT
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to reconnect %s to %s\n",
                 ctx->d1->shortname, ctx->d2->shortname);
-#endif
     GNUNET_TRANSPORT_try_connect (ctx->d1th, &ctx->d2->id);
   }
   ctx->timeout_task =
@@ -2177,10 +2063,8 @@ core_initial_iteration (void *cls, const struct GNUNET_PeerIdentity *peer,
   /* Peer not already connected, need to schedule connect request! */
   if (ctx->d1core == NULL)
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Peers are NOT connected, connecting to core!\n");
-#endif
     ctx->d1core =
         GNUNET_CORE_connect (ctx->d1->cfg, 1, ctx, &core_init_notify,
                              &connect_notify, NULL, NULL, GNUNET_NO, NULL,
@@ -2195,10 +2079,8 @@ core_initial_iteration (void *cls, const struct GNUNET_PeerIdentity *peer,
 
   if ((NULL == ctx->d2->hello) && (ctx->d2->th == NULL))        /* Do not yet have the second peer's hello, set up a task to get it */
   {
-#if DEBUG_TESTING
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                 "Don't have d2's HELLO, trying to get it!\n");
-#endif
     ctx->d2->th =
         GNUNET_TRANSPORT_connect (ctx->d2->cfg, &ctx->d2->id, NULL, NULL, NULL,
                                   NULL);
@@ -2288,11 +2170,8 @@ GNUNET_TESTING_daemons_connect (struct GNUNET_TESTING_Daemon *d1,
   ctx->connect_attempts = max_connect_attempts;
   ctx->connected = GNUNET_NO;
   ctx->send_hello = send_hello;
-#if DEBUG_TESTING
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Asked to connect peer %s to peer %s\n",
               d1->shortname, d2->shortname);
-#endif
-
   /* Core is up! Iterate over all _known_ peers first to check if we are already connected to the peer! */
   GNUNET_assert (GNUNET_OK ==
                  GNUNET_CORE_is_peer_connected (ctx->d1->cfg, &ctx->d2->id,
index 8a3ec44d43781e4164b9e192a0ec8e6f29d93e1f..2d0e9ef791af723fcf3a59ef4e8a2717ac7a5521 100644 (file)
@@ -2928,7 +2928,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
     {
       GNUNET_asprintf (&arg, "%s/friends", temp_service_path);
       procarr[pg_iter] =
-          GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL);
+       GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "mv", "mv", mytemp, arg, NULL);
       GNUNET_assert (procarr[pg_iter] != NULL);
 #if VERBOSE_TESTING
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2950,7 +2950,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
                          pg->peers[pg_iter].daemon->hostname,
                          temp_service_path);
       procarr[pg_iter] =
-          GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, NULL);
+       GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", mytemp, arg, NULL);
       GNUNET_assert (procarr[pg_iter] != NULL);
       ret = GNUNET_OS_process_wait (procarr[pg_iter]);  /* FIXME: schedule this, throttle! */
       GNUNET_OS_process_close (procarr[pg_iter]);
@@ -3127,7 +3127,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
     {
       GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path);
       procarr[pg_iter] =
-          GNUNET_OS_start_process (NULL, NULL, "mv", "mv", mytemp, arg, NULL);
+       GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "mv", "mv", mytemp, arg, NULL);
 #if VERBOSE_TESTING
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
                   _("Copying file with command cp %s %s\n"), mytemp, arg);
@@ -3147,7 +3147,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg,
                          pg->peers[pg_iter].daemon->hostname,
                          temp_service_path);
       procarr[pg_iter] =
-          GNUNET_OS_start_process (NULL, NULL, "scp", "scp", mytemp, arg, NULL);
+       GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "scp", "scp", mytemp, arg, NULL);
       GNUNET_assert (procarr[pg_iter] != NULL);
       GNUNET_OS_process_wait (procarr[pg_iter]);        /* FIXME: add scheduled blacklist file copy that parallelizes file copying! */
 
@@ -5806,7 +5806,7 @@ start_peer_helper (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 
   /* FIXME: Doesn't support ssh_port option! */
   helper->proc =
-      GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg,
+    GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", arg,
                                "peerStartHelper.pl", tempdir, NULL);
   GNUNET_assert (helper->proc != NULL);
 #if DEBUG_TESTING
@@ -6031,7 +6031,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
     {
       GNUNET_asprintf (&ssh_port_str, "%d", pg->hosts[i].sshport);
       proc =
-          GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", "-P", ssh_port_str,
+       GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", "-P", ssh_port_str,
 #if !DEBUG_TESTING
                                    "-q",
 #endif
@@ -6039,7 +6039,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
     }
     else
       proc =
-          GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", arg, "mkdir -p",
+       GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "ssh", "ssh", arg, "mkdir -p",
                                    tmpdir, NULL);
     GNUNET_assert (proc != NULL);
     GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -6262,7 +6262,7 @@ GNUNET_TESTING_daemons_start (const struct GNUNET_CONFIGURATION_Handle *cfg,
 
       /* FIXME: Doesn't support ssh_port option! */
       proc =
-          GNUNET_OS_start_process (NULL, NULL, "rsync", "rsync", "-r",
+       GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "rsync", "rsync", "-r",
                                    newservicehome, arg, NULL);
 #if DEBUG_TESTING
       GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
index 9fd62fc9f7af02af3a029e70df85473429f97b7d..2ec8d36a6154b0316b66508ab2dd4e88632dba33 100644 (file)
@@ -57,7 +57,7 @@ main (int argc, char **argv)
   /* Create RSA Private Key */
   /* openssl genrsa -out $1 1024 2> /dev/null */
   openssl =
-      GNUNET_OS_start_process (NULL, NULL, "openssl", "openssl", "genrsa",
+      GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "openssl", "openssl", "genrsa",
                                "-out", argv[1], "1024", NULL);
   if (openssl == NULL)
     return 2;
@@ -67,7 +67,7 @@ main (int argc, char **argv)
   /* Create a self-signed certificate in batch mode using rsa key */
   /* openssl req -batch -days 365 -out $2 -new -x509 -key $1 2> /dev/null */
   openssl =
-      GNUNET_OS_start_process (NULL, NULL, "openssl", "openssl", "req",
+      GNUNET_OS_start_process (GNUNET_NO, NULL, NULL, "openssl", "openssl", "req",
                                "-batch", "-days", "365", "-out", argv[2],
                                "-new", "-x509", "-key", argv[1], NULL);
   if (openssl == NULL)
index a640f38ab44fccadacdc9ddd1bc2cc9057114ffa..5a52509205cf2d5de966b7d4edc0dde726916983 100644 (file)
@@ -256,7 +256,7 @@ connect_to_peer (const char *cfgname, GNUNET_TRANSPORT_ReceiveCallback rec,
     GNUNET_DISK_directory_remove (p->servicehome);
   /*
    * p->arm_proc =
-   * GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+   * GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
    * "gnunet-service-arm", "-c", cfgname,
    * #if VERBOSE_PEERS
    * "-L", "DEBUG",
index 5142ee6421a81e4965ec2c1bb6ee348ad0f535fa..ee977f5dc79aa236fa509de217e75bc16c6781cd 100644 (file)
@@ -275,7 +275,7 @@ do_test_configuration (const struct GNUNET_CONFIGURATION_Handle *cfg)
       adv_port = bnd_port;
     if (NULL == resolver)
       resolver =
-          GNUNET_OS_start_process (NULL, NULL, "gnunet-service-resolver",
+         GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-resolver",
                                    "gnunet-service-resolver", NULL);
     resolver_users++;
     GNUNET_RESOLVER_connect (cfg);
index 2e0084ff71d7e8cc1af42b803f96b1bbeb6b6415..8ec5a5e43c1bc03a11b221918518a21e7934b16a 100644 (file)
@@ -178,7 +178,7 @@ server_load_certificate (struct Plugin *plugin)
 #endif
     errno = 0;
     cert_creation =
-        GNUNET_OS_start_process (NULL, NULL,
+        GNUNET_OS_start_process (GNUNET_NO, NULL, NULL,
                                  "gnunet-transport-certificate-creation",
                                  "gnunet-transport-certificate-creation",
                                  key_file, cert_file, NULL);
index 822a6701d62cd6db04757afa272d605e48d75a39..4510ae12c754879509cd7ac92355da536b5c9283 100644 (file)
@@ -1487,7 +1487,7 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
     if (GNUNET_OS_check_helper_binary (filenamehw) == GNUNET_YES)
     {
       plugin->server_proc =
-          GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+         GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
                                    filenamehw, filenamehw, plugin->interface,
                                    NULL);
     }
@@ -1514,7 +1514,7 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
                      absolute_filename, plugin->interface, plugin->testmode);
 #endif
     plugin->server_proc =
-        GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+        GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
                                  absolute_filename, absolute_filename, "1",
                                  NULL);
     if (plugin->server_proc == NULL)
@@ -1534,7 +1534,7 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
 #endif
 
     plugin->server_proc =
-        GNUNET_OS_start_process (plugin->server_stdin, plugin->server_stdout,
+        GNUNET_OS_start_process (GNUNET_NO, plugin->server_stdin, plugin->server_stdout,
                                  absolute_filename, absolute_filename, "2",
                                  NULL);
     if (plugin->server_proc == NULL)
index 3ef6e4b21dfec7e21c11046c94f758a04703c79c..752106bfe9ed26bedb8d4d45411fd237928525a4 100644 (file)
@@ -304,7 +304,8 @@ GNUNET_TRANSPORT_TESTING_start_peer (struct GNUNET_TRANSPORT_TESTING_handle
   }
 
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES,
+                              NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm", "-c", cfgname,
 #if VERBOSE_PEERS
                                "-L", "DEBUG",
@@ -420,7 +421,8 @@ GNUNET_TRANSPORT_TESTING_restart_peer (struct GNUNET_TRANSPORT_TESTING_handle
     goto fail;
 
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, 
+                              NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm", "-c", cfgname,
 #if VERBOSE_PEERS
                                "-L", "DEBUG",
index 8f9ba80f6e579e20806d4099d8088a31677458c1..25226a3b478a48d7bb3a0952991a06928c5de609 100644 (file)
@@ -280,9 +280,10 @@ entropy_generator (void *cls, const char *what, int printchar, int current,
   LOG (GNUNET_ERROR_TYPE_INFO, _("Starting `%s' process to generate entropy\n"),
        "find");
   genproc =
-      GNUNET_OS_start_process (NULL, NULL, "sh", "sh", "-c",
-                               "exec find / -mount -type f -exec cp {} /dev/null \\; 2>/dev/null",
-                               NULL);
+     GNUNET_OS_start_process (GNUNET_NO,
+                             NULL, NULL, "sh", "sh", "-c",
+                             "exec find / -mount -type f -exec cp {} /dev/null \\; 2>/dev/null",
+                             NULL);
 }
 
 
index e4d9f172a0bf68a8c06adaf37a5c734d1d3c2fdb..e4d5ed32b5d77e43c3747d5fa9db4125e51771d3 100644 (file)
@@ -1610,7 +1610,7 @@ GNUNET_DISK_file_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
     mode = translate_unix_perms (perm);
   }
 
-  fd = open (expfn, oflags | O_LARGEFILE, mode);
+  fd = open (expfn, oflags | O_LARGEFILE | O_NONBLOCK, mode);
   if (fd == -1)
   {
     if (0 == (flags & GNUNET_DISK_OPEN_FAILIFEXISTS))
@@ -2454,214 +2454,6 @@ GNUNET_DISK_pipe_close (struct GNUNET_DISK_PipeHandle *p)
 }
 
 
-/**
- * Creates a named pipe/FIFO and opens it
- * @param fn pointer to the name of the named pipe or to NULL
- * @param flags open flags
- * @param perm access permissions
- * @return pipe handle on success, NULL on error
- */
-struct GNUNET_DISK_FileHandle *
-GNUNET_DISK_npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags,
-                          enum GNUNET_DISK_AccessPermissions perm)
-{
-#ifdef MINGW
-  struct GNUNET_DISK_FileHandle *ret;
-  HANDLE h = NULL;
-  DWORD openMode;
-  char *name;
-
-  openMode = 0;
-  if (flags & GNUNET_DISK_OPEN_READWRITE)
-    openMode = PIPE_ACCESS_DUPLEX;
-  else if (flags & GNUNET_DISK_OPEN_READ)
-    openMode = PIPE_ACCESS_INBOUND;
-  else if (flags & GNUNET_DISK_OPEN_WRITE)
-    openMode = PIPE_ACCESS_OUTBOUND;
-
-  if (flags & GNUNET_DISK_OPEN_FAILIFEXISTS)
-    openMode |= FILE_FLAG_FIRST_PIPE_INSTANCE;
-
-  while (h == NULL)
-  {
-    DWORD error_code;
-
-    name = NULL;
-    if (*fn != NULL)
-    {
-      GNUNET_asprintf (&name, "\\\\.\\pipe\\%.246s", fn);
-#if DEBUG_NPIPE
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Trying to create an instance of named pipe `%s'\n", name);
-#endif
-      /* 1) This might work just fine with UTF-8 strings as it is.
-       * 2) This is only used by GNUnet itself, and only with latin names.
-       */
-      h = CreateNamedPipe (name, openMode | FILE_FLAG_OVERLAPPED,
-                           PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 2, 1, 1, 0,
-                           NULL);
-    }
-    else
-    {
-      GNUNET_asprintf (fn, "\\\\.\\pipe\\gnunet-%llu",
-                       GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
-                                                 UINT64_MAX));
-#if DEBUG_NPIPE
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to create unique named pipe `%s'\n",
-           *fn);
-#endif
-      h = CreateNamedPipe (*fn,
-                           openMode | FILE_FLAG_OVERLAPPED |
-                           FILE_FLAG_FIRST_PIPE_INSTANCE,
-                           PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 2, 1, 1, 0,
-                           NULL);
-    }
-    error_code = GetLastError ();
-    if (name)
-      GNUNET_free (name);
-    /* don't re-set name to NULL yet */
-    if (h == INVALID_HANDLE_VALUE)
-    {
-      SetErrnoFromWinError (error_code);
-#if DEBUG_NPIPE
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Pipe creation have failed because of %d, errno is %d\n", error_code,
-           errno);
-#endif
-      if (name == NULL)
-      {
-#if DEBUG_NPIPE
-        LOG (GNUNET_ERROR_TYPE_DEBUG,
-             "Pipe was to be unique, considering re-creation\n");
-#endif
-        GNUNET_free (*fn);
-        *fn = NULL;
-        if (error_code != ERROR_ACCESS_DENIED && error_code != ERROR_PIPE_BUSY)
-        {
-          return NULL;
-        }
-#if DEBUG_NPIPE
-        LOG (GNUNET_ERROR_TYPE_DEBUG,
-             "Pipe name was not unique, trying again\n");
-#endif
-        h = NULL;
-      }
-      else
-        return NULL;
-    }
-  }
-  errno = 0;
-
-  ret = GNUNET_malloc (sizeof (*ret));
-  ret->h = h;
-  ret->type = GNUNET_PIPE;
-
-  ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
-  ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
-
-  ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
-  ret->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
-
-  return ret;
-#else
-  if (*fn == NULL)
-  {
-    char dir[] = "/tmp/gnunet-pipe-XXXXXX";
-
-    if (mkdtemp (dir) == NULL)
-    {
-      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "mkdtemp");
-      return NULL;
-    }
-    GNUNET_asprintf (fn, "%s/child-control", dir);
-  }
-
-  if (mkfifo (*fn, translate_unix_perms (perm)) == -1)
-  {
-    if ((errno != EEXIST) || (0 != (flags & GNUNET_DISK_OPEN_FAILIFEXISTS)))
-      return NULL;
-  }
-
-  flags = flags & (~GNUNET_DISK_OPEN_FAILIFEXISTS);
-  return GNUNET_DISK_file_open (*fn, flags, perm);
-#endif
-}
-
-
-/**
- * Opens already existing named pipe/FIFO
- *
- * @param fn name of an existing named pipe
- * @param flags open flags
- * @param perm access permissions
- * @return pipe handle on success, NULL on error
- */
-struct GNUNET_DISK_FileHandle *
-GNUNET_DISK_npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
-                        enum GNUNET_DISK_AccessPermissions perm)
-{
-#ifdef MINGW
-  struct GNUNET_DISK_FileHandle *ret;
-  HANDLE h;
-  DWORD openMode;
-
-  openMode = 0;
-  if (flags & GNUNET_DISK_OPEN_READWRITE)
-    openMode = GENERIC_WRITE | GENERIC_READ;
-  else if (flags & GNUNET_DISK_OPEN_READ)
-    openMode = GENERIC_READ;
-  else if (flags & GNUNET_DISK_OPEN_WRITE)
-    openMode = GENERIC_WRITE;
-
-  h = CreateFile (fn, openMode, 0, NULL, OPEN_EXISTING,
-                  FILE_FLAG_OVERLAPPED | FILE_READ_ATTRIBUTES, NULL);
-  if (h == INVALID_HANDLE_VALUE)
-  {
-    SetErrnoFromWinError (GetLastError ());
-    return NULL;
-  }
-
-  ret = GNUNET_malloc (sizeof (*ret));
-  ret->h = h;
-  ret->type = GNUNET_PIPE;
-  ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
-  ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
-  ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
-  ret->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
-
-  return ret;
-#else
-  flags = flags & (~GNUNET_DISK_OPEN_FAILIFEXISTS);
-  return GNUNET_DISK_file_open (fn, flags, perm);
-#endif
-}
-
-
-/**
- * Closes a named pipe/FIFO
- * @param pipe named pipe
- * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
- */
-int
-GNUNET_DISK_npipe_close (struct GNUNET_DISK_FileHandle *pipe)
-{
-#ifndef MINGW
-  return close (pipe->fd) == 0 ? GNUNET_OK : GNUNET_SYSERR;
-#else
-  BOOL ret;
-
-  ret = CloseHandle (pipe->h);
-  if (!ret)
-  {
-    SetErrnoFromWinError (GetLastError ());
-    return GNUNET_SYSERR;
-  }
-  else
-    return GNUNET_OK;
-#endif
-}
-
-
 /**
  * Get the handle to a particular pipe end
  *
index e5d336e2fb88cbdc1e28bb962c4b7138b28c4649..43ec23a88278e00cc65928eba3e7b69eb80a2e3a 100644 (file)
@@ -306,7 +306,8 @@ start_helper (struct GNUNET_HELPER_Handle *h)
   h->fh_to_helper =
       GNUNET_DISK_pipe_handle (h->helper_in, GNUNET_DISK_PIPE_END_WRITE);
   h->helper_proc =
-      GNUNET_OS_start_process_vap (h->helper_in, h->helper_out,
+      GNUNET_OS_start_process_vap (GNUNET_NO,
+                                  h->helper_in, h->helper_out,
                                   h->binary_name,
                                   h->binary_argv);
   if (NULL == h->helper_proc)
index 64dce4ba3076244ce0f712b186b6d2e300007416..18dc4edaa34a4eee3cc8ba8a761fd4bb20818c6f 100644 (file)
 
 #define GNUNET_OS_CONTROL_PIPE "GNUNET_OS_CONTROL_PIPE"
 
-#define DEBUG_OS GNUNET_EXTRA_LOGGING
-
 struct GNUNET_OS_Process
 {
+  /**
+   * PID of the process.
+   */
   pid_t pid;
+
 #if WINDOWS
+  /**
+   * Process handle.
+   */
   HANDLE handle;
 #endif
-  int sig;
+
+  /**
+   * Pipe we use to signal the process (if used).
+   */
   struct GNUNET_DISK_FileHandle *control_pipe;
+
+  /**
+   * Name of the pipe, NULL for none.
+   */
+  char *childpipename;
 };
 
+
+/**
+ * Handle for 'this' process.
+ */
 static struct GNUNET_OS_Process current_process;
 
 
+/* MinGW version of named pipe API */
+#ifdef MINGW
+/**
+ * Creates a named pipe/FIFO and opens it
+ *
+ * @param fn pointer to the name of the named pipe or to NULL
+ * @param flags open flags
+ * @param perm access permissions
+ * @return pipe handle on success, NULL on error
+ */
+static struct GNUNET_DISK_FileHandle *
+npipe_create (char **fn, enum GNUNET_DISK_OpenFlags flags,
+             enum GNUNET_DISK_AccessPermissions perm)
+{
+  struct GNUNET_DISK_FileHandle *ret;
+  HANDLE h = NULL;
+  DWORD openMode;
+  char *name;
+
+  openMode = 0;
+  if (flags & GNUNET_DISK_OPEN_READWRITE)
+    openMode = PIPE_ACCESS_DUPLEX;
+  else if (flags & GNUNET_DISK_OPEN_READ)
+    openMode = PIPE_ACCESS_INBOUND;
+  else if (flags & GNUNET_DISK_OPEN_WRITE)
+    openMode = PIPE_ACCESS_OUTBOUND;
+  if (flags & GNUNET_DISK_OPEN_FAILIFEXISTS)
+    openMode |= FILE_FLAG_FIRST_PIPE_INSTANCE;
+
+  while (h == NULL)
+  {
+    DWORD error_code;
+
+    name = NULL;
+    if (*fn != NULL)
+    {
+      GNUNET_asprintf (&name, "\\\\.\\pipe\\%.246s", fn);
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Trying to create an instance of named pipe `%s'\n", name);
+      /* 1) This might work just fine with UTF-8 strings as it is.
+       * 2) This is only used by GNUnet itself, and only with latin names.
+       */
+      h = CreateNamedPipe (name, openMode | FILE_FLAG_OVERLAPPED,
+                           PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 2, 1, 1, 0,
+                           NULL);
+    }
+    else
+    {
+      GNUNET_asprintf (fn, "\\\\.\\pipe\\gnunet-%llu",
+                       GNUNET_CRYPTO_random_u64 (GNUNET_CRYPTO_QUALITY_WEAK,
+                                                 UINT64_MAX));
+      LOG (GNUNET_ERROR_TYPE_DEBUG, "Trying to create unique named pipe `%s'\n",
+           *fn);
+      h = CreateNamedPipe (*fn,
+                           openMode | FILE_FLAG_OVERLAPPED |
+                           FILE_FLAG_FIRST_PIPE_INSTANCE,
+                           PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 2, 1, 1, 0,
+                           NULL);
+    }
+    error_code = GetLastError ();
+    if (name)
+      GNUNET_free (name);
+    /* don't re-set name to NULL yet */
+    if (h == INVALID_HANDLE_VALUE)
+    {
+      SetErrnoFromWinError (error_code);
+      LOG (GNUNET_ERROR_TYPE_DEBUG,
+           "Pipe creation have failed because of %d, errno is %d\n", error_code,
+           errno);
+      if (name == NULL)
+      {
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "Pipe was to be unique, considering re-creation\n");
+        GNUNET_free (*fn);
+        *fn = NULL;
+        if (error_code != ERROR_ACCESS_DENIED && error_code != ERROR_PIPE_BUSY)
+        {
+          return NULL;
+        }
+        LOG (GNUNET_ERROR_TYPE_DEBUG,
+             "Pipe name was not unique, trying again\n");
+        h = NULL;
+      }
+      else
+        return NULL;
+    }
+  }
+  errno = 0;
+
+  ret = GNUNET_malloc (sizeof (*ret));
+  ret->h = h;
+  ret->type = GNUNET_PIPE;
+  ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
+  ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
+  ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+  ret->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+  return ret;
+}
+
+
+/**
+ * Opens already existing named pipe/FIFO
+ *
+ * @param fn name of an existing named pipe
+ * @param flags open flags
+ * @param perm access permissions
+ * @return pipe handle on success, NULL on error
+ */
+static struct GNUNET_DISK_FileHandle *
+npipe_open (const char *fn, enum GNUNET_DISK_OpenFlags flags,
+           enum GNUNET_DISK_AccessPermissions perm)
+{
+  struct GNUNET_DISK_FileHandle *ret;
+  HANDLE h;
+  DWORD openMode;
+
+  openMode = 0;
+  if (flags & GNUNET_DISK_OPEN_READWRITE)
+    openMode = GENERIC_WRITE | GENERIC_READ;
+  else if (flags & GNUNET_DISK_OPEN_READ)
+    openMode = GENERIC_READ;
+  else if (flags & GNUNET_DISK_OPEN_WRITE)
+    openMode = GENERIC_WRITE;
+
+  h = CreateFile (fn, openMode, 0, NULL, OPEN_EXISTING,
+                  FILE_FLAG_OVERLAPPED | FILE_READ_ATTRIBUTES, NULL);
+  if (h == INVALID_HANDLE_VALUE)
+  {
+    SetErrnoFromWinError (GetLastError ());
+    return NULL;
+  }
+
+  ret = GNUNET_malloc (sizeof (*ret));
+  ret->h = h;
+  ret->type = GNUNET_PIPE;
+  ret->oOverlapRead = GNUNET_malloc (sizeof (OVERLAPPED));
+  ret->oOverlapWrite = GNUNET_malloc (sizeof (OVERLAPPED));
+  ret->oOverlapRead->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+  ret->oOverlapWrite->hEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
+
+  return ret;
+}
+
+#else
+/* UNIX version of named-pipe API */
+
+/**
+ * Clean up a named pipe and the directory it was placed in.
+ *
+ * @param fn name of the pipe
+ */
+static void
+cleanup_npipe (const char *fn)
+{
+  char *dn;
+  char *dp;
+
+  if (0 != unlink (fn))
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "unlink", fn);
+  dn = GNUNET_strdup (fn);
+  dp = dirname (dn);
+  if (0 != rmdir (dp))
+    GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, "rmdir", dp);
+  GNUNET_free (dn);  
+}
+
+
+/**
+ * Setup a named pipe.
+ *
+ * @param fn where to store the name of the new pipe,
+ *           if *fn is non-null, the name of the pipe to setup
+ * @return GNUNET_OK on success
+ */
+static int
+npipe_setup (char **fn)
+{
+  if (NULL == *fn)
+  {
+    /* FIXME: hardwired '/tmp' path... is bad */
+    char dir[] = "/tmp/gnunet-pipe-XXXXXX"; 
+
+    if (NULL == mkdtemp (dir))
+    {
+      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "mkdtemp");
+      return GNUNET_SYSERR;
+    }
+    GNUNET_asprintf (fn, "%s/child-control", dir);
+  }
+  if (-1 == mkfifo (*fn, S_IRUSR | S_IWUSR))
+    return GNUNET_SYSERR;  
+  return GNUNET_OK;
+}
+
+
+/**
+ * Open an existing named pipe.
+ *
+ * @param fn name of the file
+ * @param flags flags to use
+ * @param perm permissions to use
+ * @return NULL on error
+ */
+static struct GNUNET_DISK_FileHandle *
+npipe_open (const char *fn,
+           enum GNUNET_DISK_OpenFlags flags,
+           enum GNUNET_DISK_AccessPermissions perm)
+{
+  flags = flags & (~GNUNET_DISK_OPEN_FAILIFEXISTS);
+  return GNUNET_DISK_file_open (fn, flags, perm);
+}
+#endif
+
+
 /**
  * This handler is called when there are control data to be read on the pipe
  *
@@ -64,44 +295,41 @@ static void
 parent_control_handler (void *cls,
                         const struct GNUNET_SCHEDULER_TaskContext *tc)
 {
-  struct GNUNET_DISK_FileHandle *control_pipe =
-      (struct GNUNET_DISK_FileHandle *) cls;
+  struct GNUNET_DISK_FileHandle *control_pipe = cls;
   int sig;
 
-#if DEBUG_OS
   LOG (GNUNET_ERROR_TYPE_DEBUG, "`%s' invoked because of %d\n", __FUNCTION__,
        tc->reason);
-#endif
   if (tc->reason &
       (GNUNET_SCHEDULER_REASON_SHUTDOWN | GNUNET_SCHEDULER_REASON_TIMEOUT |
        GNUNET_SCHEDULER_REASON_PREREQ_DONE))
   {
-    GNUNET_DISK_npipe_close (control_pipe);
+    GNUNET_DISK_file_close (control_pipe);
+    return;
   }
-  else
+  if (GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)) !=
+      sizeof (sig))
   {
-    if (GNUNET_DISK_file_read (control_pipe, &sig, sizeof (sig)) !=
-        sizeof (sig))
-    {
-      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
-      GNUNET_DISK_npipe_close (control_pipe);
-    }
-    else
-    {
-#if DEBUG_OS
-      LOG (GNUNET_ERROR_TYPE_DEBUG, "Got control code %d from parent\n", sig);
-#endif
-      GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
-                                      control_pipe, &parent_control_handler,
-                                      control_pipe);
-      raise (sig);
-    }
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "GNUNET_DISK_file_read");
+    GNUNET_DISK_file_close (control_pipe);
+    return;
   }
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Got control code %d from parent\n", sig);
+  GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
+                                 control_pipe, &parent_control_handler,
+                                 control_pipe);
+  raise (sig);
 }
 
 
 /**
- * Task that connects this process to its parent via pipe
+ * Task that connects this process to its parent via pipe;
+ * essentially, the parent control handler will read signal numbers
+ * from the 'GNUNET_OS_CONTROL_PIPE' (as given in an environment
+ * variable) and raise those signals.
+ *
+ * @param cls closure (unused)
+ * @param tc scheduler context (unused)
  */
 void
 GNUNET_OS_install_parent_control_handler (void *cls,
@@ -112,27 +340,26 @@ GNUNET_OS_install_parent_control_handler (void *cls,
   struct GNUNET_DISK_FileHandle *control_pipe;
 
   env_buf = getenv (GNUNET_OS_CONTROL_PIPE);
-  if ((env_buf == NULL) || (strlen (env_buf) <= 0))
+  if ( (env_buf == NULL) || (strlen (env_buf) <= 0) )
   {
-    LOG (GNUNET_ERROR_TYPE_INFO, _("Not installing a handler because $%s=%s\n"),
-         GNUNET_OS_CONTROL_PIPE, env_buf);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+        "Not installing a handler because $%s is empty\n",
+         GNUNET_OS_CONTROL_PIPE);
     putenv ("GNUNET_OS_CONTROL_PIPE=");
     return;
   }
   control_pipe =
-      GNUNET_DISK_npipe_open (env_buf, GNUNET_DISK_OPEN_READ,
-                              GNUNET_DISK_PERM_USER_READ |
-                              GNUNET_DISK_PERM_USER_WRITE);
-  if (control_pipe == NULL)
+    npipe_open (env_buf, GNUNET_DISK_OPEN_READ,
+               GNUNET_DISK_PERM_USER_READ |
+               GNUNET_DISK_PERM_USER_WRITE);
+  if (NULL == control_pipe)
   {
     LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_WARNING, "open", env_buf);
     putenv ("GNUNET_OS_CONTROL_PIPE=");
     return;
   }
-#if DEBUG_OS
   LOG (GNUNET_ERROR_TYPE_DEBUG,
        "Adding parent control handler pipe `%s' to the scheduler\n", env_buf);
-#endif
   GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, control_pipe,
                                   &parent_control_handler, control_pipe);
   putenv ("GNUNET_OS_CONTROL_PIPE=");
@@ -160,104 +387,64 @@ GNUNET_OS_process_current ()
 }
 
 
+/**
+ * Sends a signal to the process
+ *
+ * @param proc pointer to process structure
+ * @param sig signal
+ * @return 0 on success, -1 on error
+ */
 int
 GNUNET_OS_process_kill (struct GNUNET_OS_Process *proc, int sig)
 {
-#if ENABLE_WINDOWS_WORKAROUNDS
-  int res = 0;
-  int ret = 0;
+  int ret;
 
+#if !WINDOWS
+  if ( (NULL == proc->control_pipe) &&
+       (NULL != proc->childpipename) )
+    proc->control_pipe = npipe_open (proc->childpipename,
+                                    GNUNET_DISK_OPEN_WRITE,
+                                    GNUNET_DISK_PERM_USER_READ |
+                                    GNUNET_DISK_PERM_USER_WRITE);    
+#endif
+  if (NULL == proc->control_pipe)
+  {
+#if WINDOWS
+    /* no pipe and windows? can't do this */
+    errno = EINVAL;
+    return -1;
+#else
+    return kill (proc->pid, sig);
+#endif    
+  }
   ret = GNUNET_DISK_file_write (proc->control_pipe, &sig, sizeof (sig));
-  if (ret != sizeof (sig))
+  if (ret == sizeof (sig))
+    return 0;
+  /* pipe failed, try other methods */
+  switch (sig)
   {
-    if (errno == ECOMM)
-    {
-      /* Child process is not controllable via pipe */
-#if DEBUG_OS
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Child process is not controllable, will kill it directly\n");
-#endif
-    }
-    else if (errno == EPIPE)
+  case SIGHUP:
+  case SIGINT:
+  case SIGKILL:
+  case SIGTERM:
+#if WINDOWS && !defined(__CYGWIN__)
+    if (0 == TerminateProcess (proc->handle, 0))
     {
-#if DEBUG_OS
-      LOG (GNUNET_ERROR_TYPE_DEBUG,
-           "Failed to write into control pipe, because pipe is invalid (the child is most likely dead)\n");
-#endif
+      /* FIXME: set 'errno' */
+      return -1;
     }
-    else
-      LOG (GNUNET_ERROR_TYPE_WARNING,
-           "Failed to write into control pipe , errno is %d\n", errno);
-#if WINDOWS && !defined(__CYGWIN__)
-    TerminateProcess (proc->handle, 0);
+    return 0;
 #else
-    PLIBC_KILL (proc->pid, sig);
-#endif
-  }
-  else
-  {
-#if DEBUG_OS
-    LOG (GNUNET_ERROR_TYPE_DEBUG,
-         "Wrote control code into control pipe, now waiting\n");
+    return PLIBC_KILL (proc->pid, sig);
 #endif
-
+  default:
 #if WINDOWS
-    /* Give it 3 seconds to die, then kill it in a nice Windows-specific way */
-    if (WaitForSingleObject (proc->handle, 3000) != WAIT_OBJECT_0)
-      TerminateProcess (proc->handle, 0);
-    res = 0;
+    errno = EINVAL;
+    return -1;
 #else
-    struct GNUNET_NETWORK_FDSet *rfds;
-    struct GNUNET_NETWORK_FDSet *efds;
-
-    rfds = GNUNET_NETWORK_fdset_create ();
-    efds = GNUNET_NETWORK_fdset_create ();
-
-    GNUNET_NETWORK_fdset_handle_set (rfds, proc->control_pipe);
-    GNUNET_NETWORK_fdset_handle_set (efds, proc->control_pipe);
-
-    /* Ndurner thought this up, and i have no idea what it does.
-     * There's have never been any code to answer the shutdown call
-     * (write a single int into the pipe, so that this function can read it).
-     * On *nix select() will probably tell that pipe is ready
-     * for reading, once the other process shuts down,
-     * but the read () call will fail, triggering a kill ()
-     * on the pid that is already dead. This will probably result in non-0
-     * return from kill(), and therefore from this function.
-     */
-    while (1)
-    {
-      ret =
-          GNUNET_NETWORK_socket_select (rfds, NULL, efds,
-                                        GNUNET_TIME_relative_multiply
-                                        (GNUNET_TIME_relative_get_unit (),
-                                         5000));
-
-      if (ret < 1 ||
-          GNUNET_NETWORK_fdset_handle_isset (efds, proc->control_pipe))
-      {
-        /* Just to be sure */
-        PLIBC_KILL (proc->pid, sig);
-        res = 0;
-        break;
-      }
-      else
-      {
-        if (GNUNET_DISK_file_read (proc->control_pipe, &ret, sizeof (ret)) !=
-            GNUNET_OK)
-          res = PLIBC_KILL (proc->pid, sig);
-
-        /* Child signaled shutdown is in progress */
-        continue;
-      }
-    }
-#endif
+    return kill (proc->pid, sig);
+#endif    
   }
-
-  return res;
-#else
-  return kill (proc->pid, sig);
-#endif
 }
 
 /**
@@ -279,13 +466,18 @@ GNUNET_OS_process_close (struct GNUNET_OS_Process *proc)
 {
 #if ENABLE_WINDOWS_WORKAROUNDS
   if (proc->control_pipe)
-    GNUNET_DISK_npipe_close (proc->control_pipe);
+    GNUNET_DISK_file_close (proc->control_pipe);
 #endif
 // FIXME NILS
 #ifdef WINDOWS
   if (proc->handle != NULL)
     CloseHandle (proc->handle);
 #endif
+  if (NULL != proc->childpipename)
+  {
+    cleanup_npipe (proc->childpipename);
+    GNUNET_free (proc->childpipename);
+  }
   GNUNET_free (proc);
 }
 
@@ -417,10 +609,8 @@ GNUNET_OS_set_process_priority (struct GNUNET_OS_Process *proc,
     }
   }
 #else
-#if DEBUG_OS
   LOG (GNUNET_ERROR_TYPE_DEBUG | GNUNET_ERROR_TYPE_BULK,
        "Priority management not availabe for this platform\n");
-#endif
 #endif
   return GNUNET_OK;
 }
@@ -531,6 +721,7 @@ CreateCustomEnvTable (char **vars)
 /**
  * Start a process.
  *
+ * @param pipe_control should a pipe be used to send signals to the child?
  * @param pipe_stdin pipe to use to send input to child process (or NULL)
  * @param pipe_stdout pipe to use to get output from child process (or NULL)
  * @param filename name of the binary
@@ -538,32 +729,25 @@ CreateCustomEnvTable (char **vars)
  * @return pointer to process structure of the new process, NULL on error
  */
 struct GNUNET_OS_Process *
-GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process_vap (int pipe_control,
+                            struct GNUNET_DISK_PipeHandle *pipe_stdin,
                             struct GNUNET_DISK_PipeHandle *pipe_stdout,
                             const char *filename, 
                             char *const argv[])
 {
-#if ENABLE_WINDOWS_WORKAROUNDS
+#ifndef MINGW
   char *childpipename = NULL;
-  struct GNUNET_DISK_FileHandle *control_pipe = NULL;
-#endif
   struct GNUNET_OS_Process *gnunet_proc = NULL;
-
-#ifndef MINGW
   pid_t ret;
   int fd_stdout_write;
   int fd_stdout_read;
   int fd_stdin_read;
   int fd_stdin_write;
 
-#if ENABLE_WINDOWS_WORKAROUNDS
-  control_pipe =
-      GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
-                                GNUNET_DISK_PERM_USER_READ |
-                                GNUNET_DISK_PERM_USER_WRITE);
-  if (control_pipe == NULL)
-    return NULL;
-#endif
+  if ( (GNUNET_YES == pipe_control) &&
+       (GNUNET_OK != 
+       npipe_setup (&childpipename)) )
+    return NULL;  
   if (pipe_stdout != NULL)
   {
     GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle
@@ -585,34 +769,24 @@ GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
   }
 
   ret = fork ();
-  if (ret != 0)
+  if (-1 == ret)
   {
-    if (ret == -1)
-    {
-      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
-#if ENABLE_WINDOWS_WORKAROUNDS
-      GNUNET_DISK_npipe_close (control_pipe);
-#endif
-    }
-    else
-    {
-      gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
-      gnunet_proc->pid = ret;
-#if ENABLE_WINDOWS_WORKAROUNDS
-      gnunet_proc->control_pipe = control_pipe;
-#endif
-    }
-#if ENABLE_WINDOWS_WORKAROUNDS
-    GNUNET_free (childpipename);
-#endif
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
+    GNUNET_free_non_null (childpipename);
+    return NULL;
+  }
+  if (0 != ret)
+  {
+    gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
+    gnunet_proc->pid = ret;
+    gnunet_proc->childpipename = childpipename;
     return gnunet_proc;
   }
-
-#if ENABLE_WINDOWS_WORKAROUNDS
-  setenv (GNUNET_OS_CONTROL_PIPE, childpipename, 1);
-  GNUNET_free (childpipename);
-#endif
-
+  if (NULL != childpipename)
+  {
+    setenv (GNUNET_OS_CONTROL_PIPE, childpipename, 1);
+    GNUNET_free (childpipename);
+  }
   if (pipe_stdout != NULL)
   {
     GNUNET_break (0 == close (fd_stdout_read));
@@ -633,6 +807,8 @@ GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
   LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "execvp", filename);
   _exit (1);
 #else
+  char *childpipename = NULL;
+  struct GNUNET_OS_Process *gnunet_proc = NULL;
   char *arg;
   unsigned int cmdlen;
   char *cmd, *idx;
@@ -749,26 +925,31 @@ GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
                                        &stdout_handle, sizeof (HANDLE));
     start.hStdOutput = stdout_handle;
   }
-
-  control_pipe =
-      GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
-                                GNUNET_DISK_PERM_USER_READ |
-                                GNUNET_DISK_PERM_USER_WRITE);
-  if (control_pipe == NULL)
+  if (GNUNET_YES == pipe_control)
   {
-    GNUNET_free (cmd);
-    GNUNET_free (path);
-    return NULL;
+    control_pipe =
+      npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
+                   GNUNET_DISK_PERM_USER_READ |
+                   GNUNET_DISK_PERM_USER_WRITE);
+    if (control_pipe == NULL)
+    {
+      GNUNET_free (cmd);
+      GNUNET_free (path);
+      return NULL;
+    }
+  }
+  if (NULL != childpipename)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n",
+        childpipename);
+    GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE);
+    GNUNET_asprintf (&our_env[1], "%s", childpipename);
+    our_env[2] = NULL;
+  }
+  else
+  {
+    our_env[0] = NULL;
   }
-
-#if DEBUG_OS
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n",
-       childpipename);
-#endif
-
-  GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE);
-  GNUNET_asprintf (&our_env[1], "%s", childpipename);
-  our_env[2] = NULL;
   env_block = CreateCustomEnvTable (our_env);
   GNUNET_free (our_env[0]);
   GNUNET_free (our_env[1]);
@@ -808,6 +989,7 @@ GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
 /**
  * Start a process.
  *
+ * @param pipe_control should a pipe be used to send signals to the child?
  * @param pipe_stdin pipe to use to send input to child process (or NULL)
  * @param pipe_stdout pipe to use to get output from child process (or NULL)
  * @param filename name of the binary
@@ -815,7 +997,8 @@ GNUNET_OS_start_process_vap (struct GNUNET_DISK_PipeHandle *pipe_stdin,
  * @return pointer to process structure of the new process, NULL on error
  */
 struct GNUNET_OS_Process *
-GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process_va (int pipe_control,
+                           struct GNUNET_DISK_PipeHandle *pipe_stdin,
                             struct GNUNET_DISK_PipeHandle *pipe_stdout,
                             const char *filename, va_list va)
 {
@@ -835,7 +1018,8 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
   while (NULL != (argv[argc] = va_arg (ap, char *)))
     argc++;
   va_end (ap);
-  ret = GNUNET_OS_start_process_vap (pipe_stdin,
+  ret = GNUNET_OS_start_process_vap (pipe_control,
+                                    pipe_stdin,
                                     pipe_stdout,
                                     filename,
                                     argv);
@@ -848,6 +1032,7 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
 /**
  * Start a process.
  *
+ * @param pipe_control should a pipe be used to send signals to the child?
  * @param pipe_stdin pipe to use to send input to child process (or NULL)
  * @param pipe_stdout pipe to use to get output from child process (or NULL)
  * @param filename name of the binary
@@ -857,7 +1042,8 @@ GNUNET_OS_start_process_va (struct GNUNET_DISK_PipeHandle *pipe_stdin,
  *
  */
 struct GNUNET_OS_Process *
-GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
+GNUNET_OS_start_process (int pipe_control,
+                        struct GNUNET_DISK_PipeHandle *pipe_stdin,
                          struct GNUNET_DISK_PipeHandle *pipe_stdout,
                          const char *filename, ...)
 {
@@ -865,7 +1051,7 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
   va_list ap;
 
   va_start (ap, filename);
-  ret = GNUNET_OS_start_process_va (pipe_stdin, pipe_stdout, filename, ap);
+  ret = GNUNET_OS_start_process_va (pipe_control, pipe_stdin, pipe_stdout, filename, ap);
   va_end (ap);
   return ret;
 }
@@ -874,6 +1060,7 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
 /**
  * Start a process.
  *
+ * @param pipe_control should a pipe be used to send signals to the child?
  * @param lsocks array of listen sockets to dup systemd-style (or NULL);
  *         must be NULL on platforms where dup is not supported
  * @param filename name of the binary
@@ -881,20 +1068,17 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
  * @return process ID of the new process, -1 on error
  */
 struct GNUNET_OS_Process *
-GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
+GNUNET_OS_start_process_v (int pipe_control,
+                          const SOCKTYPE *lsocks,
                            const char *filename,
                            char *const argv[])
 {
-#if ENABLE_WINDOWS_WORKAROUNDS
-  struct GNUNET_DISK_FileHandle *control_pipe = NULL;
-  char *childpipename = NULL;
-#endif
-
 #ifndef MINGW
   pid_t ret;
   char lpid[16];
   char fds[16];
   struct GNUNET_OS_Process *gnunet_proc = NULL;
+  char *childpipename = NULL;
   int i;
   int j;
   int k;
@@ -903,15 +1087,9 @@ GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
   int *lscp;
   unsigned int ls;
 
-#if ENABLE_WINDOWS_WORKAROUNDS
-  control_pipe =
-      GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
-                                GNUNET_DISK_PERM_USER_READ |
-                                GNUNET_DISK_PERM_USER_WRITE);
-  if (control_pipe == NULL)
-    return NULL;
-#endif
-
+  if ( (GNUNET_YES == pipe_control) &&
+       (GNUNET_OK != npipe_setup (&childpipename)) )
+    return NULL;  
   lscp = NULL;
   ls = 0;
   if (lsocks != NULL)
@@ -922,36 +1100,26 @@ GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
     GNUNET_array_append (lscp, ls, -1);
   }
   ret = fork ();
-  if (ret != 0)
+  if (-1 == ret)
   {
-    if (ret == -1)
-    {
-      LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
-#if ENABLE_WINDOWS_WORKAROUNDS
-      GNUNET_DISK_npipe_close (control_pipe);
-#endif
-    }
-    else
-    {
-      gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
-      gnunet_proc->pid = ret;
-#if ENABLE_WINDOWS_WORKAROUNDS
-      gnunet_proc->control_pipe = control_pipe;
-
-#endif
-    }
+    LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "fork");
+    GNUNET_free_non_null (childpipename);
+    GNUNET_array_grow (lscp, ls, 0);
+    return NULL;
+  }
+  if (0 != ret)
+  {
+    gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
+    gnunet_proc->pid = ret;
+    gnunet_proc->childpipename = childpipename;  
     GNUNET_array_grow (lscp, ls, 0);
-#if ENABLE_WINDOWS_WORKAROUNDS
-    GNUNET_free (childpipename);
-#endif
     return gnunet_proc;
   }
-
-#if ENABLE_WINDOWS_WORKAROUNDS
-  setenv (GNUNET_OS_CONTROL_PIPE, childpipename, 1);
-  GNUNET_free (childpipename);
-#endif
-
+  if (NULL != childpipename)
+  {
+    setenv (GNUNET_OS_CONTROL_PIPE, childpipename, 1);
+    GNUNET_free (childpipename);
+  }
   if (lscp != NULL)
   {
     /* read systemd documentation... */
@@ -999,6 +1167,8 @@ GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
   LOG_STRERROR_FILE (GNUNET_ERROR_TYPE_ERROR, "execvp", filename);
   _exit (1);
 #else
+  struct GNUNET_DISK_FileHandle *control_pipe = NULL;
+  char *childpipename = NULL;
   char **arg, **non_const_argv;
   unsigned int cmdlen;
   char *cmd, *idx;
@@ -1006,9 +1176,7 @@ GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
   PROCESS_INFORMATION proc;
   int argcount = 0;
   struct GNUNET_OS_Process *gnunet_proc = NULL;
-
   char path[MAX_PATH + 1];
-
   char *our_env[5] = { NULL, NULL, NULL, NULL, NULL };
   char *env_block = NULL;
   char *pathbuf;
@@ -1023,7 +1191,7 @@ GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
   HANDLE lsocks_read;
   HANDLE lsocks_write;
   wchar_t wpath[MAX_PATH + 1], wcmd[32768];
-
+  int env_off;
   int fail;
 
   /* Search in prefix dir (hopefully - the directory from which
@@ -1130,15 +1298,18 @@ GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
   memset (&start, 0, sizeof (start));
   start.cb = sizeof (start);
 
-  control_pipe =
-      GNUNET_DISK_npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
-                                GNUNET_DISK_PERM_USER_READ |
-                                GNUNET_DISK_PERM_USER_WRITE);
-  if (control_pipe == NULL)
+  if (GNUNET_YES == pipe_control)
   {
-    GNUNET_free (cmd);
-    GNUNET_free (path);
-    return NULL;
+    control_pipe =
+      npipe_create (&childpipename, GNUNET_DISK_OPEN_WRITE,
+                   GNUNET_DISK_PERM_USER_READ |
+                   GNUNET_DISK_PERM_USER_WRITE);
+    if (control_pipe == NULL)
+    {
+      GNUNET_free (cmd);
+      GNUNET_free (path);
+      return NULL;
+    }
   }
   if (lsocks != NULL && lsocks[0] != INVALID_SOCKET)
   {
@@ -1160,29 +1331,25 @@ GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
                                        &lsocks_read, sizeof (HANDLE));
   }
 
-#if DEBUG_OS
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n",
-       childpipename);
-#endif
-
-  GNUNET_asprintf (&our_env[0], "%s=", GNUNET_OS_CONTROL_PIPE);
-  GNUNET_asprintf (&our_env[1], "%s", childpipename);
-  GNUNET_free (childpipename);
-  if (lsocks == NULL || lsocks[0] == INVALID_SOCKET)
-    our_env[2] = NULL;
-  else
+  env_off = 0;
+  if (NULL != childpipename)
+  {
+    LOG (GNUNET_ERROR_TYPE_DEBUG, "Opened the parent end of the pipe `%s'\n",
+        childpipename);
+    GNUNET_asprintf (&our_env[env_off++], "%s=", GNUNET_OS_CONTROL_PIPE);
+    GNUNET_asprintf (&our_env[env_off++], "%s", childpipename);
+    GNUNET_free (childpipename);
+  }
+  if ( (lsocks != NULL) && (lsocks[0] != INVALID_SOCKET))
   {
     /*This will tell the child that we're going to send lsocks over the pipe*/
-    GNUNET_asprintf (&our_env[2], "%s=", "GNUNET_OS_READ_LSOCKS");
-    GNUNET_asprintf (&our_env[3], "%lu", lsocks_read);
-    our_env[4] = NULL;
+    GNUNET_asprintf (&our_env[env_off++], "%s=", "GNUNET_OS_READ_LSOCKS");
+    GNUNET_asprintf (&our_env[env_off++], "%lu", lsocks_read);
   }
+  our_env[env_off++] = NULL;
   env_block = CreateCustomEnvTable (our_env);
-  GNUNET_free_non_null (our_env[0]);
-  GNUNET_free_non_null (our_env[1]);
-  GNUNET_free_non_null (our_env[2]);
-  GNUNET_free_non_null (our_env[3]);
-
+  while (0 > env_off)
+    GNUNET_free_non_null (our_env[--env_off]);
   if (ERROR_SUCCESS != plibc_conv_to_win_pathwconv(path, wpath)
       || ERROR_SUCCESS != plibc_conv_to_win_pathwconv(cmd, wcmd)
       || !CreateProcessW
@@ -1191,8 +1358,9 @@ GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
   {
     SetErrnoFromWinError (GetLastError ());
     LOG_STRERROR (GNUNET_ERROR_TYPE_ERROR, "CreateProcess");
-    GNUNET_DISK_npipe_close (control_pipe);
-    if (lsocks != NULL)
+    if (NULL != control_pipe)
+      GNUNET_DISK_file_close (control_pipe);
+    if (NULL != lsocks)
       GNUNET_DISK_pipe_close (lsocks_pipe);
     GNUNET_free (env_block);
     GNUNET_free (cmd);
@@ -1286,11 +1454,11 @@ GNUNET_OS_start_process_v (const SOCKTYPE *lsocks,
      */
     TerminateProcess (gnunet_proc->handle, 0);
     CloseHandle (gnunet_proc->handle);
-    GNUNET_DISK_npipe_close (gnunet_proc->control_pipe);
+    if (NULL != gnunet_proc->control_pipe)
+      GNUNET_DISK_file_close (gnunet_proc->control_pipe);
     GNUNET_free (gnunet_proc);
     return NULL;
   }
-
   return gnunet_proc;
 #endif
 }
@@ -1599,7 +1767,7 @@ GNUNET_OS_command_run (GNUNET_OS_LineProcessor proc, void *proc_cls,
   if (NULL == opipe)
     return NULL;
   va_start (ap, binary);
-  eip = GNUNET_OS_start_process_va (NULL, opipe, binary, ap);
+  eip = GNUNET_OS_start_process_va (GNUNET_NO, NULL, opipe, binary, ap);
   va_end (ap);
   if (NULL == eip)
   {
index f1cecd4effba507f5c69272d0902d83a94ab2e38..c54672f5fa49a6d52be8b5c35930e94b18886f05 100644 (file)
@@ -818,13 +818,11 @@ GNUNET_SCHEDULER_run (GNUNET_SCHEDULER_Task task, void *task_cls)
   current_lifeness = GNUNET_YES;
   GNUNET_SCHEDULER_add_continuation (task, task_cls,
                                      GNUNET_SCHEDULER_REASON_STARTUP);
-#if ENABLE_WINDOWS_WORKAROUNDS
   active_task = (void *) (long) -1;     /* force passing of sanity check */
   GNUNET_SCHEDULER_add_now_with_lifeness (GNUNET_NO,
                                           &GNUNET_OS_install_parent_control_handler,
                                           NULL);
   active_task = NULL;
-#endif
   last_tr = 0;
   busy_wait_warning = 0;
   while (GNUNET_OK == check_lifeness ())
index b6b9d6178a2ed93f5accac4c94d134bf54bea830..cdf1f660d2fffff794037cf3119f5f98d4a94ba1 100644 (file)
@@ -314,7 +314,7 @@ runone ()
     break;
   }
 
-  proc = GNUNET_OS_start_process (NULL, pipe_stdout,
+  proc = GNUNET_OS_start_process (GNUNET_NO, NULL, pipe_stdout,
 #if MINGW
                                   "test_common_logging_dummy",
 #else
index 178a1d9ef3dbbd6676bcf0a442a0affb658ea3eb..54638c12f6961bd359ce61ed2119babbe29e0fb0 100644 (file)
@@ -126,7 +126,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   }
 
   proc =
-      GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn,
+      GNUNET_OS_start_process (GNUNET_NO, hello_pipe_stdin, hello_pipe_stdout, fn,
                                "test_gnunet_echo_hello", "-", NULL);
   GNUNET_free (fn);
 
index 4ad5a2cf583021a975436f0f8a17c8fd6afa969e..67d5f464074a95d408ddf176150275fd17968f1c 100644 (file)
@@ -393,7 +393,7 @@ check ()
   pfx = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR);
   GNUNET_asprintf (&fn, "%s%cgnunet-service-resolver", pfx, DIR_SEPARATOR);
   GNUNET_free (pfx);
-  proc = GNUNET_OS_start_process (NULL, NULL, fn, "gnunet-service-resolver",
+  proc = GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, fn, "gnunet-service-resolver",
 #if VERBOSE
                                   "-L", "DEBUG",
 #endif
index 88de0b81b5db53ec966890bec4343de13c99efde..570776a8109e2da80b634743bd9c01b482892fbe 100644 (file)
@@ -97,7 +97,9 @@ check ()
   GNUNET_free (r);
   b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "ASCII");
   WANT ("TEST", b);
+  GNUNET_log_skip (2, GNUNET_NO);
   b = GNUNET_STRINGS_to_utf8 ("TEST", 4, "unknown");
+  GNUNET_log_skip (0, GNUNET_YES);
   WANT ("TEST", b);
   return 0;
 }
index 90895e452a9044ad114526f3fd45343b2b648126..005c7bd07a2f84294c57cb01335e3d8d5339a924 100644 (file)
@@ -441,7 +441,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
   p->cfg = GNUNET_CONFIGURATION_create ();
 #if START_ARM
   p->arm_proc =
-      GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+      GNUNET_OS_start_process (GNUNET_YES, NULL, NULL, "gnunet-service-arm",
                                "gnunet-service-arm",
 #if VERBOSE
                                "-L", "DEBUG",