- docs
[oweals/gnunet.git] / src / testbed / gnunet-helper-testbed.c
index ab0a595d2642242f1ffd4f306536009c8eae6f97..be9154fdc7bbe2a3033e5a99497e9bcb17f57927 100644 (file)
  *          This helper monitors for three termination events.  They are: (1)The
  *          stdin of the helper is closed for reading; (2)the helper received
  *          SIGTERM/SIGINT; (3)the testbed crashed.  In case of events 1 and 2
- *          the helper kills the testbed service.
+ *          the helper kills the testbed service.  When testbed crashed (event
+ *          3), the helper should send a SIGTERM to its own process group; this
+ *          behaviour will help terminate any child processes (peers) testbed
+ *          has started and prevents them from leaking and running forever.
  *
  * @author Sree Harsha Totakura <sreeharsha@totakura.in>
  */
@@ -294,7 +297,12 @@ child_death_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   {
     GNUNET_OS_process_destroy (testbed);
     testbed = NULL;
-    shutdown_now ();
+    /* Send SIGTERM to our process group */
+    if (0 != PLIBC_KILL (0, SIGTERM))
+    {
+      GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "signal");
+      shutdown_now ();          /* Couldn't send the signal, we shutdown frowning */
+    }
     return;
   }
   LOG_DEBUG ("Child hasn't died.  Resuming to monitor its status\n");
@@ -393,7 +401,7 @@ tokenizer_cb (void *cls, void *client,
     hostname[hostname_size] = '\0';
   }
   test_system =
-      GNUNET_TESTING_system_create ("testbed-helper", trusted_ip, hostname);
+      GNUNET_TESTING_system_create ("testbed-helper", trusted_ip, hostname, NULL);
   GNUNET_free_non_null (hostname);
   hostname = NULL;
   GNUNET_assert (NULL != test_system);