LRN: Fix automake deps to allow -j* builds again
[oweals/gnunet.git] / src / util / crypto_random.c
index 4fcb157d9221286ceac1c2f9d17caed71e245cb7..5928b96ea7bffacdfb2e99c1ef708c00752548c5 100644 (file)
@@ -188,7 +188,7 @@ GNUNET_CRYPTO_random_disable_entropy_gathering ()
  * Process ID of the "find" process that we use for
  * entropy gathering.
  */
-static pid_t genproc;
+static struct GNUNET_OS_Process *genproc;
 
 /**
  * Function called by libgcrypt whenever we are
@@ -206,16 +206,17 @@ entropy_generator (void *cls,
     return;
   if (current == total)
     {
-      if (genproc != 0)
+      if (genproc != NULL)
         {
-          if (0 != PLIBC_KILL (genproc, SIGTERM))
+          if (0 != GNUNET_OS_process_kill (genproc, SIGTERM))
             GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill");
           GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc));
-          genproc = 0;
+          GNUNET_OS_process_close (genproc);
+          genproc = NULL;
         }
       return;
     }
-  if (genproc != 0)
+  if (genproc != NULL)
     {
       ret = GNUNET_OS_process_status (genproc, &type, &code);
       if (ret == GNUNET_NO)
@@ -225,10 +226,11 @@ entropy_generator (void *cls,
           GNUNET_break (0);
           return;
         }
-      if (0 != PLIBC_KILL (genproc, SIGTERM))
+      if (0 != GNUNET_OS_process_kill (genproc, SIGTERM))
         GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill");
       GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc));
-      genproc = 0;
+      GNUNET_OS_process_close (genproc);
+      genproc = NULL;
     }
   GNUNET_log (GNUNET_ERROR_TYPE_INFO,
               _("Starting `%s' process to generate entropy\n"), "find");
@@ -243,17 +245,17 @@ entropy_generator (void *cls,
 static void
 killfind ()
 {
-  if (genproc != 0)
+  if (genproc != NULL)
     {
-      PLIBC_KILL (genproc, SIGKILL);
-      genproc = 0;
+      GNUNET_OS_process_kill (genproc, SIGKILL);
+      GNUNET_OS_process_close (genproc);
+      genproc = NULL;
     }
 }
 
 
 void __attribute__ ((constructor)) GNUNET_CRYPTO_random_init ()
 {
-  SRANDOM (time (NULL));
   gcry_control (GCRYCTL_DISABLE_SECMEM, 0);
   if (!gcry_check_version (GCRYPT_VERSION))
     {
@@ -268,6 +270,7 @@ void __attribute__ ((constructor)) GNUNET_CRYPTO_random_init ()
 #endif
   gcry_set_progress_handler (&entropy_generator, NULL);
   atexit (&killfind);
+  SRANDOM (time (NULL) ^ GNUNET_CRYPTO_random_u32 (GNUNET_CRYPTO_QUALITY_NONCE, UINT32_MAX));
 }
 
 
@@ -279,3 +282,4 @@ void __attribute__ ((destructor)) GNUNET_CRYPTO_random_fini ()
 
 
 /* end of crypto_random.c */
+