aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/arm/arm_api.c8
-rw-r--r--src/arm/do_start_process.c8
-rw-r--r--src/arm/gnunet-service-arm.c50
-rw-r--r--src/core/test_core_api.c12
-rw-r--r--src/core/test_core_api_reliability.c12
-rw-r--r--src/core/test_core_api_start_only.c12
-rw-r--r--src/core/test_core_quota_compliance.c6
-rw-r--r--src/datastore/perf_datastore_api.c10
-rw-r--r--src/datastore/test_datastore_api.c10
-rw-r--r--src/datastore/test_datastore_api_management.c10
-rw-r--r--src/dht/test_dht_api.c10
-rw-r--r--src/fs/test_fs.c5
-rw-r--r--src/fs/test_fs_download.c12
-rw-r--r--src/fs/test_fs_download_indexed.c12
-rw-r--r--src/fs/test_fs_download_persistence.c12
-rw-r--r--src/fs/test_fs_download_recursive.c8
-rw-r--r--src/fs/test_fs_list_indexed.c12
-rw-r--r--src/fs/test_fs_namespace.c12
-rw-r--r--src/fs/test_fs_namespace_list_updateable.c12
-rw-r--r--src/fs/test_fs_publish.c12
-rw-r--r--src/fs/test_fs_publish_persistence.c12
-rw-r--r--src/fs/test_fs_search.c12
-rw-r--r--src/fs/test_fs_search_persistence.c12
-rw-r--r--src/fs/test_fs_search_ranking.c6
-rw-r--r--src/fs/test_fs_start_stop.c12
-rw-r--r--src/fs/test_fs_unindex.c12
-rw-r--r--src/fs/test_fs_unindex_persistence.c12
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c12
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_learning.c22
-rw-r--r--src/include/gnunet_os_lib.h108
-rw-r--r--src/include/gnunet_testing_lib.h2
-rw-r--r--src/monkey/test_gnunet_monkey.c9
-rwxr-xr-xsrc/peerinfo/perf_peerinfo_api.c11
-rw-r--r--src/peerinfo/test_peerinfo_api.c10
-rw-r--r--src/statistics/test_statistics_api.c20
-rw-r--r--src/statistics/test_statistics_api_loop.c10
-rw-r--r--src/testing/test_testing_topology.c6
-rw-r--r--src/testing/testing.c56
-rw-r--r--src/testing/testing_group.c34
-rw-r--r--src/transport/plugin_transport_tcp.c20
-rw-r--r--src/transport/plugin_transport_udp.c20
-rw-r--r--src/transport/plugin_transport_wlan.c6
-rw-r--r--src/transport/test_quota_compliance.c10
-rw-r--r--src/transport/test_transport_api.c10
-rw-r--r--src/transport/test_transport_api_reliability.c10
-rw-r--r--src/util/crypto_random.c24
-rw-r--r--src/util/os_priority.c225
-rw-r--r--src/util/scheduler.c2
-rw-r--r--src/util/test_os_priority.c12
-rw-r--r--src/util/test_os_start_process.c10
-rw-r--r--src/util/test_resolver_api.c10
-rw-r--r--src/vpn/gnunet-daemon-vpn.c16
-rw-r--r--src/vpn/gnunet-service-dns.c4
53 files changed, 665 insertions, 337 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c
index fb4f3a02d..81f1c2d5c 100644
--- a/src/arm/arm_api.c
+++ b/src/arm/arm_api.c
@@ -375,7 +375,7 @@ arm_service_report (void *cls,
375 const struct GNUNET_SCHEDULER_TaskContext *tc) 375 const struct GNUNET_SCHEDULER_TaskContext *tc)
376{ 376{
377 struct RequestContext *pos = cls; 377 struct RequestContext *pos = cls;
378 pid_t pid; 378 GNUNET_OS_Process *proc;
379 char *binary; 379 char *binary;
380 char *config; 380 char *config;
381 char *loprefix; 381 char *loprefix;
@@ -454,7 +454,7 @@ arm_service_report (void *cls,
454 ) 454 )
455 { 455 {
456 /* we're clearly running a test, don't daemonize */ 456 /* we're clearly running a test, don't daemonize */
457 pid = do_start_process (NULL, 457 proc = do_start_process (NULL,
458 loprefix, 458 loprefix,
459 binary, 459 binary,
460 "-c", config, 460 "-c", config,
@@ -467,7 +467,7 @@ arm_service_report (void *cls,
467 } 467 }
468 else 468 else
469 { 469 {
470 pid = do_start_process (NULL, 470 proc = do_start_process (NULL,
471 loprefix, 471 loprefix,
472 binary, 472 binary,
473 "-c", config, 473 "-c", config,
@@ -482,7 +482,7 @@ arm_service_report (void *cls,
482 GNUNET_free (config); 482 GNUNET_free (config);
483 GNUNET_free (loprefix); 483 GNUNET_free (loprefix);
484 GNUNET_free (lopostfix); 484 GNUNET_free (lopostfix);
485 if (pid == -1) 485 if (proc == NULL)
486 { 486 {
487 if (pos->callback != NULL) 487 if (pos->callback != NULL)
488 pos->callback (pos->cls, GNUNET_SYSERR); 488 pos->callback (pos->cls, GNUNET_SYSERR);
diff --git a/src/arm/do_start_process.c b/src/arm/do_start_process.c
index d616ac2b7..7d691ce60 100644
--- a/src/arm/do_start_process.c
+++ b/src/arm/do_start_process.c
@@ -12,7 +12,7 @@
12 * @param ... more arguments, NULL terminated 12 * @param ... more arguments, NULL terminated
13 * @return PID of the started process, -1 on error 13 * @return PID of the started process, -1 on error
14 */ 14 */
15static pid_t 15static GNUNET_OS_Process *
16do_start_process (const int *lsocks, 16do_start_process (const int *lsocks,
17 const char *first_arg, ...) 17 const char *first_arg, ...)
18{ 18{
@@ -24,7 +24,7 @@ do_start_process (const int *lsocks,
24 char *pos; 24 char *pos;
25 char *cp; 25 char *cp;
26 const char *last; 26 const char *last;
27 pid_t pid; 27 GNUNET_OS_Process *proc;
28 28
29 argv_size = 1; 29 argv_size = 1;
30 va_start (ap, first_arg); 30 va_start (ap, first_arg);
@@ -88,9 +88,9 @@ do_start_process (const int *lsocks,
88 while (NULL != (arg = (va_arg (ap, const char*)))); 88 while (NULL != (arg = (va_arg (ap, const char*))));
89 va_end (ap); 89 va_end (ap);
90 argv[argv_size] = NULL; 90 argv[argv_size] = NULL;
91 pid = GNUNET_OS_start_process_v (lsocks, argv[0], argv); 91 proc = GNUNET_OS_start_process_v (lsocks, argv[0], argv);
92 while (argv_size > 0) 92 while (argv_size > 0)
93 GNUNET_free (argv[--argv_size]); 93 GNUNET_free (argv[--argv_size]);
94 GNUNET_free (argv); 94 GNUNET_free (argv);
95 return pid; 95 return proc;
96} 96}
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c
index 2eb21a068..543e65557 100644
--- a/src/arm/gnunet-service-arm.c
+++ b/src/arm/gnunet-service-arm.c
@@ -91,9 +91,9 @@ struct ServiceList
91 struct GNUNET_SERVER_Client *killing_client; 91 struct GNUNET_SERVER_Client *killing_client;
92 92
93 /** 93 /**
94 * Process ID of the child. 94 * Process structure pointer of the child.
95 */ 95 */
96 pid_t pid; 96 GNUNET_OS_Process *proc;
97 97
98 /** 98 /**
99 * Last time the config of this service was 99 * Last time the config of this service was
@@ -199,11 +199,11 @@ config_change_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
199 /* FIXME: this test for config change is a bit too coarse grained */ 199 /* FIXME: this test for config change is a bit too coarse grained */
200 if ( (0 == STAT (pos->config, &sbuf)) && 200 if ( (0 == STAT (pos->config, &sbuf)) &&
201 (pos->mtime < sbuf.st_mtime) && 201 (pos->mtime < sbuf.st_mtime) &&
202 (pos->pid != 0) ) 202 (pos->proc != NULL) )
203 { 203 {
204 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 204 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
205 _("Restarting service `%s' due to configuration file change.\n")); 205 _("Restarting service `%s' due to configuration file change.\n"));
206 if (0 != PLIBC_KILL (pos->pid, SIGTERM)) 206 if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM))
207 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 207 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
208 else 208 else
209 pos->backoff = GNUNET_TIME_UNIT_MILLISECONDS; 209 pos->backoff = GNUNET_TIME_UNIT_MILLISECONDS;
@@ -414,7 +414,7 @@ start_process (struct ServiceList *sl,
414 sl->name, sl->binary, sl->config); 414 sl->name, sl->binary, sl->config);
415#endif 415#endif
416 if (GNUNET_YES == use_debug) 416 if (GNUNET_YES == use_debug)
417 sl->pid = do_start_process (lsocks, 417 sl->proc = do_start_process (lsocks,
418 loprefix, 418 loprefix,
419 sl->binary, 419 sl->binary,
420 "-c", sl->config, 420 "-c", sl->config,
@@ -422,19 +422,24 @@ start_process (struct ServiceList *sl,
422 options, 422 options,
423 NULL); 423 NULL);
424 else 424 else
425 sl->pid = do_start_process (lsocks, 425 sl->proc = do_start_process (lsocks,
426 loprefix, 426 loprefix,
427 sl->binary, 427 sl->binary,
428 "-c", sl->config, 428 "-c", sl->config,
429 options, 429 options,
430 NULL); 430 NULL);
431 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 431 if (sl->proc == NULL)
432 _("Starting service `%s' (PID: %d)\n"), 432 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
433 sl->name, 433 _("Failed to start service `%s'\n"),
434 (int) sl->pid); 434 sl->name);
435 else
436 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
437 _("Starting service `%s' (PID: %d)\n"),
438 sl->name,
439 (int) GNUNET_OS_process_get_pid (sl->proc));
435 GNUNET_free (loprefix); 440 GNUNET_free (loprefix);
436 GNUNET_free (options); 441 GNUNET_free (options);
437 /* FIXME: should check sl->pid */ 442 /* FIXME: should check sl->proc */
438} 443}
439 444
440 445
@@ -568,7 +573,7 @@ stop_service (struct GNUNET_SERVER_Client *client,
568 running = pos; 573 running = pos;
569 return; 574 return;
570 } 575 }
571 if (pos->pid == 0) 576 if (pos->proc == NULL)
572 { 577 {
573 /* process is in delayed restart, simply remove it! */ 578 /* process is in delayed restart, simply remove it! */
574 free_entry (pos); 579 free_entry (pos);
@@ -581,7 +586,7 @@ stop_service (struct GNUNET_SERVER_Client *client,
581 "Sending kill signal to service `%s', waiting for process to die.\n", 586 "Sending kill signal to service `%s', waiting for process to die.\n",
582 servicename); 587 servicename);
583#endif 588#endif
584 if (0 != PLIBC_KILL (pos->pid, SIGTERM)) 589 if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM))
585 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 590 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
586 pos->next = running; 591 pos->next = running;
587 running = pos; 592 running = pos;
@@ -653,7 +658,7 @@ handle_stop (void *cls,
653 658
654/** 659/**
655 * Remove all entries for tasks that are not running 660 * Remove all entries for tasks that are not running
656 * (pid = 0) from the running list (they will no longer 661 * (proc = NULL) from the running list (they will no longer
657 * be restarted since we are shutting down). 662 * be restarted since we are shutting down).
658 */ 663 */
659static void 664static void
@@ -668,7 +673,7 @@ clean_up_running ()
668 while (NULL != pos) 673 while (NULL != pos)
669 { 674 {
670 next = pos->next; 675 next = pos->next;
671 if (pos->pid == 0) 676 if (pos->proc == NULL)
672 { 677 {
673 if (prev == NULL) 678 if (prev == NULL)
674 running = next; 679 running = next;
@@ -727,13 +732,13 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
727 pos = running; 732 pos = running;
728 while (NULL != pos) 733 while (NULL != pos)
729 { 734 {
730 if (pos->pid != 0) 735 if (pos->proc != NULL)
731 { 736 {
732 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 737 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
733 "Stopping service `%s' (PID: %d)\n", 738 "Stopping service `%s' (PID: %d)\n",
734 pos->name, 739 pos->name,
735 pos->pid); 740 GNUNET_OS_process_get_pid (pos->proc));
736 if (0 != PLIBC_KILL (pos->pid, SIGTERM)) 741 if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM))
737 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 742 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
738 } 743 }
739 pos = pos->next; 744 pos = pos->next;
@@ -773,7 +778,7 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
773 pos = running; 778 pos = running;
774 while (pos != NULL) 779 while (pos != NULL)
775 { 780 {
776 if ( (pos->pid == 0) && 781 if ( (pos->proc == NULL) &&
777 (GNUNET_YES != in_shutdown) ) 782 (GNUNET_YES != in_shutdown) )
778 { 783 {
779 if (GNUNET_TIME_absolute_get_remaining (pos->restartAt).rel_value == 0) 784 if (GNUNET_TIME_absolute_get_remaining (pos->restartAt).rel_value == 0)
@@ -845,12 +850,12 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
845 while (NULL != (pos = next)) 850 while (NULL != (pos = next))
846 { 851 {
847 next = pos->next; 852 next = pos->next;
848 if (pos->pid == 0) 853 if (pos->proc == NULL)
849 { 854 {
850 prev = pos; 855 prev = pos;
851 continue; 856 continue;
852 } 857 }
853 if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->pid, 858 if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->proc,
854 &statusType, 859 &statusType,
855 &statusCode))) || 860 &statusCode))) ||
856 ( (ret == GNUNET_NO) || 861 ( (ret == GNUNET_NO) ||
@@ -876,7 +881,8 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
876 statstr = _( /* process termination method */ "unknown"); 881 statstr = _( /* process termination method */ "unknown");
877 statcode = 0; 882 statcode = 0;
878 } 883 }
879 pos->pid = 0; 884 GNUNET_OS_process_close (pos->proc);
885 pos->proc = NULL;
880 if (NULL != pos->killing_client) 886 if (NULL != pos->killing_client)
881 { 887 {
882 if (prev == NULL) 888 if (prev == NULL)
diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c
index b04430eea..a4c3b0a78 100644
--- a/src/core/test_core_api.c
+++ b/src/core/test_core_api.c
@@ -54,7 +54,7 @@ struct PeerContext
54 struct GNUNET_MessageHeader *hello; 54 struct GNUNET_MessageHeader *hello;
55 int connect_status; 55 int connect_status;
56#if START_ARM 56#if START_ARM
57 pid_t arm_pid; 57 GNUNET_OS_Process *arm_proc;
58#endif 58#endif
59}; 59};
60 60
@@ -289,7 +289,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
289{ 289{
290 p->cfg = GNUNET_CONFIGURATION_create (); 290 p->cfg = GNUNET_CONFIGURATION_create ();
291#if START_ARM 291#if START_ARM
292 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 292 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
293 "gnunet-service-arm", 293 "gnunet-service-arm",
294#if VERBOSE 294#if VERBOSE
295 "-L", "DEBUG", 295 "-L", "DEBUG",
@@ -332,12 +332,14 @@ static void
332stop_arm (struct PeerContext *p) 332stop_arm (struct PeerContext *p)
333{ 333{
334#if START_ARM 334#if START_ARM
335 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 335 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
336 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 336 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
337 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 337 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
338 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 338 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 339 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
340 "ARM process %u stopped\n", p->arm_pid); 340 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_pid));
341 GNUNET_OS_process_close (p->arm_proc);
342 p->arm_proc = NULL;
341#endif 343#endif
342 GNUNET_CONFIGURATION_destroy (p->cfg); 344 GNUNET_CONFIGURATION_destroy (p->cfg);
343} 345}
diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c
index b25cb89f2..0b3be2f82 100644
--- a/src/core/test_core_api_reliability.c
+++ b/src/core/test_core_api_reliability.c
@@ -74,7 +74,7 @@ struct PeerContext
74 struct GNUNET_MessageHeader *hello; 74 struct GNUNET_MessageHeader *hello;
75 int connect_status; 75 int connect_status;
76#if START_ARM 76#if START_ARM
77 pid_t arm_pid; 77 GNUNET_OS_Process *arm_proc;
78#endif 78#endif
79}; 79};
80 80
@@ -436,7 +436,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
436{ 436{
437 p->cfg = GNUNET_CONFIGURATION_create (); 437 p->cfg = GNUNET_CONFIGURATION_create ();
438#if START_ARM 438#if START_ARM
439 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 439 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
440 "gnunet-service-arm", 440 "gnunet-service-arm",
441#if VERBOSE 441#if VERBOSE
442 "-L", "DEBUG", 442 "-L", "DEBUG",
@@ -479,12 +479,14 @@ static void
479stop_arm (struct PeerContext *p) 479stop_arm (struct PeerContext *p)
480{ 480{
481#if START_ARM 481#if START_ARM
482 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 482 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
483 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 483 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
484 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 484 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
485 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 485 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
487 "ARM process %u stopped\n", p->arm_pid); 487 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
488 GNUNET_OS_process_close (p->arm_proc);
489 p->arm_proc = NULL;
488#endif 490#endif
489 GNUNET_CONFIGURATION_destroy (p->cfg); 491 GNUNET_CONFIGURATION_destroy (p->cfg);
490} 492}
diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c
index b55d3c972..e82f12ed3 100644
--- a/src/core/test_core_api_start_only.c
+++ b/src/core/test_core_api_start_only.c
@@ -49,7 +49,7 @@ struct PeerContext
49 struct GNUNET_CORE_Handle *ch; 49 struct GNUNET_CORE_Handle *ch;
50 struct GNUNET_PeerIdentity id; 50 struct GNUNET_PeerIdentity id;
51#if START_ARM 51#if START_ARM
52 pid_t arm_pid; 52 GNUNET_OS_Process *arm_proc;
53#endif 53#endif
54}; 54};
55 55
@@ -153,7 +153,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
153{ 153{
154 p->cfg = GNUNET_CONFIGURATION_create (); 154 p->cfg = GNUNET_CONFIGURATION_create ();
155#if START_ARM 155#if START_ARM
156 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 156 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
157 "gnunet-service-arm", 157 "gnunet-service-arm",
158#if VERBOSE 158#if VERBOSE
159 "-L", "DEBUG", 159 "-L", "DEBUG",
@@ -193,12 +193,14 @@ static void
193stop_arm (struct PeerContext *p) 193stop_arm (struct PeerContext *p)
194{ 194{
195#if START_ARM 195#if START_ARM
196 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 196 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
197 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 197 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
198 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 198 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
199 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 199 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 200 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
201 "ARM process %u stopped\n", p->arm_pid); 201 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
202 GNUNET_OS_process_close (p->arm_proc);
203 p->arm_proc = NULL;
202#endif 204#endif
203 GNUNET_CONFIGURATION_destroy (p->cfg); 205 GNUNET_CONFIGURATION_destroy (p->cfg);
204} 206}
diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c
index d4df96611..99d9ed4ad 100644
--- a/src/core/test_core_quota_compliance.c
+++ b/src/core/test_core_quota_compliance.c
@@ -479,7 +479,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
479{ 479{
480 p->cfg = GNUNET_CONFIGURATION_create (); 480 p->cfg = GNUNET_CONFIGURATION_create ();
481#if START_ARM 481#if START_ARM
482 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 482 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
483 "gnunet-service-arm", 483 "gnunet-service-arm",
484#if VERBOSE 484#if VERBOSE
485 "-L", "DEBUG", 485 "-L", "DEBUG",
@@ -539,10 +539,12 @@ static void
539stop_arm (struct PeerContext *p) 539stop_arm (struct PeerContext *p)
540{ 540{
541#if START_ARM 541#if START_ARM
542 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 542 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
543 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 543 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
544 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 544 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
545 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 545 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
546 GNUNET_OS_process_close (p->arm_proc);
547 p->arm_proc = NULL;
546 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 548 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
547 "ARM process %u stopped\n", p->arm_pid); 549 "ARM process %u stopped\n", p->arm_pid);
548#endif 550#endif
diff --git a/src/datastore/perf_datastore_api.c b/src/datastore/perf_datastore_api.c
index bb4f88cf3..07bb16016 100644
--- a/src/datastore/perf_datastore_api.c
+++ b/src/datastore/perf_datastore_api.c
@@ -372,7 +372,7 @@ run (void *cls,
372static int 372static int
373check () 373check ()
374{ 374{
375 pid_t pid; 375 GNUNET_OS_Process *proc;
376 char cfg_name[128]; 376 char cfg_name[128];
377 char *const argv[] = { 377 char *const argv[] = {
378 "perf-datastore-api", 378 "perf-datastore-api",
@@ -391,7 +391,7 @@ check ()
391 sizeof (cfg_name), 391 sizeof (cfg_name),
392 "test_datastore_api_data_%s.conf", 392 "test_datastore_api_data_%s.conf",
393 plugin_name); 393 plugin_name);
394 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 394 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
395 "gnunet-service-arm", 395 "gnunet-service-arm",
396#if VERBOSE 396#if VERBOSE
397 "-L", "DEBUG", 397 "-L", "DEBUG",
@@ -400,12 +400,14 @@ check ()
400 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 400 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
401 argv, "perf-datastore-api", "nohelp", 401 argv, "perf-datastore-api", "nohelp",
402 options, &run, NULL); 402 options, &run, NULL);
403 if (0 != PLIBC_KILL (pid, SIGTERM)) 403 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
404 { 404 {
405 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 405 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
406 ok = 1; 406 ok = 1;
407 } 407 }
408 GNUNET_OS_process_wait(pid); 408 GNUNET_OS_process_wait (proc);
409 GNUNET_OS_process_close (proc);
410 proc = NULL;
409 return ok; 411 return ok;
410} 412}
411 413
diff --git a/src/datastore/test_datastore_api.c b/src/datastore/test_datastore_api.c
index ae7782d6c..feba0b7ac 100644
--- a/src/datastore/test_datastore_api.c
+++ b/src/datastore/test_datastore_api.c
@@ -641,7 +641,7 @@ check ()
641{ 641{
642 char cfg_name[128]; 642 char cfg_name[128];
643#if START_DATASTORE 643#if START_DATASTORE
644 pid_t pid; 644 GNUNET_OS_Process *proc;
645#endif 645#endif
646 char *const argv[] = { 646 char *const argv[] = {
647 "test-datastore-api", 647 "test-datastore-api",
@@ -660,7 +660,7 @@ check ()
660 "test_datastore_api_data_%s.conf", 660 "test_datastore_api_data_%s.conf",
661 plugin_name); 661 plugin_name);
662#if START_DATASTORE 662#if START_DATASTORE
663 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 663 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
664 "gnunet-service-arm", 664 "gnunet-service-arm",
665#if VERBOSE 665#if VERBOSE
666 "-L", "DEBUG", 666 "-L", "DEBUG",
@@ -671,12 +671,14 @@ check ()
671 argv, "test-datastore-api", "nohelp", 671 argv, "test-datastore-api", "nohelp",
672 options, &run, NULL); 672 options, &run, NULL);
673#if START_DATASTORE 673#if START_DATASTORE
674 if (0 != PLIBC_KILL (pid, SIGTERM)) 674 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
675 { 675 {
676 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 676 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
677 ok = 1; 677 ok = 1;
678 } 678 }
679 GNUNET_OS_process_wait(pid); 679 GNUNET_OS_process_wait (proc);
680 GNUNET_OS_process_close (proc);
681 proc = NULL;
680#endif 682#endif
681 if (ok != 0) 683 if (ok != 0)
682 fprintf (stderr, "Missed some testcases: %u\n", ok); 684 fprintf (stderr, "Missed some testcases: %u\n", ok);
diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c
index 72760de7a..fbb8795a6 100644
--- a/src/datastore/test_datastore_api_management.c
+++ b/src/datastore/test_datastore_api_management.c
@@ -350,7 +350,7 @@ run (void *cls,
350static int 350static int
351check () 351check ()
352{ 352{
353 pid_t pid; 353 GNUNET_OS_Process *proc;
354 char cfg_name[128]; 354 char cfg_name[128];
355 char *const argv[] = { 355 char *const argv[] = {
356 "test-datastore-api-management", 356 "test-datastore-api-management",
@@ -368,7 +368,7 @@ check ()
368 sizeof (cfg_name), 368 sizeof (cfg_name),
369 "test_datastore_api_data_%s.conf", 369 "test_datastore_api_data_%s.conf",
370 plugin_name); 370 plugin_name);
371 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 371 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
372 "gnunet-service-arm", 372 "gnunet-service-arm",
373#if VERBOSE 373#if VERBOSE
374 "-L", "DEBUG", 374 "-L", "DEBUG",
@@ -377,12 +377,14 @@ check ()
377 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 377 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
378 argv, "test-datastore-api", "nohelp", 378 argv, "test-datastore-api", "nohelp",
379 options, &run, NULL); 379 options, &run, NULL);
380 if (0 != PLIBC_KILL (pid, SIGTERM)) 380 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
381 { 381 {
382 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 382 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
383 ok = 1; 383 ok = 1;
384 } 384 }
385 GNUNET_OS_process_wait(pid); 385 GNUNET_OS_process_wait (proc);
386 GNUNET_OS_process_close (proc);
387 proc = NULL;
386 if (ok != 0) 388 if (ok != 0)
387 fprintf (stderr, "Missed some testcases: %u\n", ok); 389 fprintf (stderr, "Missed some testcases: %u\n", ok);
388 return ok; 390 return ok;
diff --git a/src/dht/test_dht_api.c b/src/dht/test_dht_api.c
index 2145be843..5ef70407c 100644
--- a/src/dht/test_dht_api.c
+++ b/src/dht/test_dht_api.c
@@ -85,7 +85,7 @@ struct PeerContext
85 struct GNUNET_DHT_FindPeerHandle *find_peer_handle; 85 struct GNUNET_DHT_FindPeerHandle *find_peer_handle;
86 86
87#if START_ARM 87#if START_ARM
88 pid_t arm_pid; 88 GNUNET_OS_Process *arm_proc;
89#endif 89#endif
90}; 90};
91 91
@@ -121,9 +121,11 @@ static void
121stop_arm (struct PeerContext *p) 121stop_arm (struct PeerContext *p)
122{ 122{
123#if START_ARM 123#if START_ARM
124 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 124 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
125 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 125 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
126 GNUNET_OS_process_wait (p->arm_pid); 126 GNUNET_OS_process_wait (p->arm_proc);
127 GNUNET_OS_process_close (p->arm_proc);
128 p->arm_proc = NULL;
127#endif 129#endif
128 GNUNET_CONFIGURATION_destroy (p->cfg); 130 GNUNET_CONFIGURATION_destroy (p->cfg);
129} 131}
@@ -453,7 +455,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
453{ 455{
454 p->cfg = GNUNET_CONFIGURATION_create (); 456 p->cfg = GNUNET_CONFIGURATION_create ();
455#if START_ARM 457#if START_ARM
456 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 458 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
457 "gnunet-service-arm", 459 "gnunet-service-arm",
458#if VERBOSE_ARM 460#if VERBOSE_ARM
459 "-L", "DEBUG", 461 "-L", "DEBUG",
diff --git a/src/fs/test_fs.c b/src/fs/test_fs.c
index f9621949e..a97faf94f 100644
--- a/src/fs/test_fs.c
+++ b/src/fs/test_fs.c
@@ -104,7 +104,7 @@ int
104main (int argc, char *argv[]) 104main (int argc, char *argv[])
105{ 105{
106#if START_DAEMON 106#if START_DAEMON
107 pid_t daemon; 107 GNUNET_OS_Process *daemon;
108#endif 108#endif
109 int ok; 109 int ok;
110 struct GNUNET_ECRS_URI *uri; 110 struct GNUNET_ECRS_URI *uri;
@@ -132,7 +132,7 @@ main (int argc, char *argv[])
132 } 132 }
133#if START_DAEMON 133#if START_DAEMON
134 daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO); 134 daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
135 GNUNET_GE_ASSERT (NULL, daemon > 0); 135 GNUNET_GE_ASSERT (NULL, daemon != NULL);
136 CHECK (GNUNET_OK == 136 CHECK (GNUNET_OK ==
137 GNUNET_wait_for_daemon_running (NULL, cfg, 137 GNUNET_wait_for_daemon_running (NULL, cfg,
138 60 * GNUNET_CRON_SECONDS)); 138 60 * GNUNET_CRON_SECONDS));
@@ -250,6 +250,7 @@ FAILURE:
250 250
251#if START_DAEMON 251#if START_DAEMON
252 GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon)); 252 GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
253 GNUNET_OS_process_close (daemon);
253#endif 254#endif
254 GNUNET_GC_free (cfg); 255 GNUNET_GC_free (cfg);
255 256
diff --git a/src/fs/test_fs_download.c b/src/fs/test_fs_download.c
index 848c95954..305dee07e 100644
--- a/src/fs/test_fs_download.c
+++ b/src/fs/test_fs_download.c
@@ -52,7 +52,7 @@ struct PeerContext
52{ 52{
53 struct GNUNET_CONFIGURATION_Handle *cfg; 53 struct GNUNET_CONFIGURATION_Handle *cfg;
54#if START_ARM 54#if START_ARM
55 pid_t arm_pid; 55 GNUNET_OS_Process *arm_proc;
56#endif 56#endif
57}; 57};
58 58
@@ -249,7 +249,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
249{ 249{
250 p->cfg = GNUNET_CONFIGURATION_create (); 250 p->cfg = GNUNET_CONFIGURATION_create ();
251#if START_ARM 251#if START_ARM
252 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 252 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
253 "gnunet-service-arm", 253 "gnunet-service-arm",
254#if VERBOSE 254#if VERBOSE
255 "-L", "DEBUG", 255 "-L", "DEBUG",
@@ -264,12 +264,14 @@ static void
264stop_arm (struct PeerContext *p) 264stop_arm (struct PeerContext *p)
265{ 265{
266#if START_ARM 266#if START_ARM
267 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 267 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
268 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 268 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
269 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 269 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
270 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 270 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 271 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
272 "ARM process %u stopped\n", p->arm_pid); 272 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
273 GNUNET_OS_process_close (p->arm_proc);
274 p->arm_proc = NULL;
273#endif 275#endif
274 GNUNET_CONFIGURATION_destroy (p->cfg); 276 GNUNET_CONFIGURATION_destroy (p->cfg);
275} 277}
diff --git a/src/fs/test_fs_download_indexed.c b/src/fs/test_fs_download_indexed.c
index ac4f57bb9..b55f2221b 100644
--- a/src/fs/test_fs_download_indexed.c
+++ b/src/fs/test_fs_download_indexed.c
@@ -52,7 +52,7 @@ struct PeerContext
52{ 52{
53 struct GNUNET_CONFIGURATION_Handle *cfg; 53 struct GNUNET_CONFIGURATION_Handle *cfg;
54#if START_ARM 54#if START_ARM
55 pid_t arm_pid; 55 GNUNET_OS_Process *arm_proc;
56#endif 56#endif
57}; 57};
58 58
@@ -251,7 +251,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
251{ 251{
252 p->cfg = GNUNET_CONFIGURATION_create (); 252 p->cfg = GNUNET_CONFIGURATION_create ();
253#if START_ARM 253#if START_ARM
254 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 254 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
255 "gnunet-service-arm", 255 "gnunet-service-arm",
256#if VERBOSE 256#if VERBOSE
257 "-L", "DEBUG", 257 "-L", "DEBUG",
@@ -266,12 +266,14 @@ static void
266stop_arm (struct PeerContext *p) 266stop_arm (struct PeerContext *p)
267{ 267{
268#if START_ARM 268#if START_ARM
269 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 269 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
270 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 270 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
271 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 271 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
272 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 272 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 273 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
274 "ARM process %u stopped\n", p->arm_pid); 274 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
275 GNUNET_OS_process_close (p->arm_proc);
276 p->arm_proc = NULL;
275#endif 277#endif
276 GNUNET_CONFIGURATION_destroy (p->cfg); 278 GNUNET_CONFIGURATION_destroy (p->cfg);
277} 279}
diff --git a/src/fs/test_fs_download_persistence.c b/src/fs/test_fs_download_persistence.c
index 4560985c9..6bb4ab865 100644
--- a/src/fs/test_fs_download_persistence.c
+++ b/src/fs/test_fs_download_persistence.c
@@ -52,7 +52,7 @@ struct PeerContext
52{ 52{
53 struct GNUNET_CONFIGURATION_Handle *cfg; 53 struct GNUNET_CONFIGURATION_Handle *cfg;
54#if START_ARM 54#if START_ARM
55 pid_t arm_pid; 55 GNUNET_OS_Process *arm_proc;
56#endif 56#endif
57}; 57};
58 58
@@ -310,7 +310,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
310{ 310{
311 p->cfg = GNUNET_CONFIGURATION_create (); 311 p->cfg = GNUNET_CONFIGURATION_create ();
312#if START_ARM 312#if START_ARM
313 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 313 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
314 "gnunet-service-arm", 314 "gnunet-service-arm",
315#if VERBOSE 315#if VERBOSE
316 "-L", "DEBUG", 316 "-L", "DEBUG",
@@ -325,12 +325,14 @@ static void
325stop_arm (struct PeerContext *p) 325stop_arm (struct PeerContext *p)
326{ 326{
327#if START_ARM 327#if START_ARM
328 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 328 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
329 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 329 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
330 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 330 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
331 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 331 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
332 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 332 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
333 "ARM process %u stopped\n", p->arm_pid); 333 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
334 GNUNET_OS_process_close (p->arm_proc);
335 p->arm_proc = NULL;
334#endif 336#endif
335 GNUNET_CONFIGURATION_destroy (p->cfg); 337 GNUNET_CONFIGURATION_destroy (p->cfg);
336} 338}
diff --git a/src/fs/test_fs_download_recursive.c b/src/fs/test_fs_download_recursive.c
index 20f681f11..a60a2da9a 100644
--- a/src/fs/test_fs_download_recursive.c
+++ b/src/fs/test_fs_download_recursive.c
@@ -29,7 +29,7 @@
29#include "gnunet_util.h" 29#include "gnunet_util.h"
30#include "gnunet_fsui_lib.h" 30#include "gnunet_fsui_lib.h"
31 31
32#define DEBUG_VERBOSE GNUNET_NO 32#define DEBUG_VERBOSE GNUNET_YES
33 33
34#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GNUNET_GE_BREAK(ectx, 0); goto FAILURE; } 34#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GNUNET_GE_BREAK(ectx, 0); goto FAILURE; }
35 35
@@ -256,7 +256,7 @@ int
256main (int argc, char *argv[]) 256main (int argc, char *argv[])
257{ 257{
258#if START_DAEMON 258#if START_DAEMON
259 pid_t daemon; 259 GNUNET_OS_Process *daemon;
260#endif 260#endif
261 int ok; 261 int ok;
262 char *fn = NULL; 262 char *fn = NULL;
@@ -284,7 +284,7 @@ main (int argc, char *argv[])
284 GNUNET_disk_directory_remove (NULL, 284 GNUNET_disk_directory_remove (NULL,
285 "/tmp/gnunet-fsui-recursive_download_test/"); 285 "/tmp/gnunet-fsui-recursive_download_test/");
286 daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO); 286 daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
287 GNUNET_GE_ASSERT (NULL, daemon > 0); 287 GNUNET_GE_ASSERT (NULL, daemon != NULL);
288 CHECK (GNUNET_OK == 288 CHECK (GNUNET_OK ==
289 GNUNET_wait_for_daemon_running (NULL, cfg, 289 GNUNET_wait_for_daemon_running (NULL, cfg,
290 30 * GNUNET_CRON_SECONDS)); 290 30 * GNUNET_CRON_SECONDS));
@@ -372,6 +372,8 @@ FAILURE:
372 372
373#if START_DAEMON 373#if START_DAEMON
374 GNUNET_GE_BREAK (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon)); 374 GNUNET_GE_BREAK (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
375 GNUNET_OS_process_close (daemon);
376 daemon = NULL;
375#endif 377#endif
376 GNUNET_GC_free (cfg); 378 GNUNET_GC_free (cfg);
377 return (ok == GNUNET_YES) ? 0 : 1; 379 return (ok == GNUNET_YES) ? 0 : 1;
diff --git a/src/fs/test_fs_list_indexed.c b/src/fs/test_fs_list_indexed.c
index dd2b30417..1221ff6c4 100644
--- a/src/fs/test_fs_list_indexed.c
+++ b/src/fs/test_fs_list_indexed.c
@@ -56,7 +56,7 @@ struct PeerContext
56{ 56{
57 struct GNUNET_CONFIGURATION_Handle *cfg; 57 struct GNUNET_CONFIGURATION_Handle *cfg;
58#if START_ARM 58#if START_ARM
59 pid_t arm_pid; 59 GNUNET_OS_Process *arm_proc;
60#endif 60#endif
61}; 61};
62 62
@@ -199,7 +199,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
199{ 199{
200 p->cfg = GNUNET_CONFIGURATION_create (); 200 p->cfg = GNUNET_CONFIGURATION_create ();
201#if START_ARM 201#if START_ARM
202 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 202 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
203 "gnunet-service-arm", 203 "gnunet-service-arm",
204#if VERBOSE 204#if VERBOSE
205 "-L", "DEBUG", 205 "-L", "DEBUG",
@@ -214,12 +214,14 @@ static void
214stop_arm (struct PeerContext *p) 214stop_arm (struct PeerContext *p)
215{ 215{
216#if START_ARM 216#if START_ARM
217 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 217 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
218 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 218 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
219 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 219 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
220 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 220 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
222 "ARM process %u stopped\n", p->arm_pid); 222 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
223 GNUNET_OS_process_close (p->arm_proc);
224 p->arm_proc = NULL;
223#endif 225#endif
224 GNUNET_CONFIGURATION_destroy (p->cfg); 226 GNUNET_CONFIGURATION_destroy (p->cfg);
225} 227}
diff --git a/src/fs/test_fs_namespace.c b/src/fs/test_fs_namespace.c
index f197b4749..efe44af0b 100644
--- a/src/fs/test_fs_namespace.c
+++ b/src/fs/test_fs_namespace.c
@@ -59,7 +59,7 @@ struct PeerContext
59{ 59{
60 struct GNUNET_CONFIGURATION_Handle *cfg; 60 struct GNUNET_CONFIGURATION_Handle *cfg;
61#if START_ARM 61#if START_ARM
62 pid_t arm_pid; 62 GNUNET_OS_Process *arm_proc;
63#endif 63#endif
64}; 64};
65 65
@@ -69,7 +69,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
69{ 69{
70 p->cfg = GNUNET_CONFIGURATION_create (); 70 p->cfg = GNUNET_CONFIGURATION_create ();
71#if START_ARM 71#if START_ARM
72 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 72 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
73 "gnunet-service-arm", 73 "gnunet-service-arm",
74#if VERBOSE 74#if VERBOSE
75 "-L", "DEBUG", 75 "-L", "DEBUG",
@@ -84,12 +84,14 @@ static void
84stop_arm (struct PeerContext *p) 84stop_arm (struct PeerContext *p)
85{ 85{
86#if START_ARM 86#if START_ARM
87 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 87 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
88 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 88 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
89 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 89 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
90 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 90 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
91 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 91 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
92 "ARM process %u stopped\n", p->arm_pid); 92 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
93 GNUNET_OS_process_close (p->arm_proc);
94 p->arm_proc = NULL;
93#endif 95#endif
94 GNUNET_CONFIGURATION_destroy (p->cfg); 96 GNUNET_CONFIGURATION_destroy (p->cfg);
95} 97}
diff --git a/src/fs/test_fs_namespace_list_updateable.c b/src/fs/test_fs_namespace_list_updateable.c
index fc6b1537a..1cf8653bb 100644
--- a/src/fs/test_fs_namespace_list_updateable.c
+++ b/src/fs/test_fs_namespace_list_updateable.c
@@ -55,7 +55,7 @@ struct PeerContext
55{ 55{
56 struct GNUNET_CONFIGURATION_Handle *cfg; 56 struct GNUNET_CONFIGURATION_Handle *cfg;
57#if START_ARM 57#if START_ARM
58 pid_t arm_pid; 58 GNUNET_OS_Process *arm_proc;
59#endif 59#endif
60}; 60};
61 61
@@ -73,7 +73,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
73{ 73{
74 p->cfg = GNUNET_CONFIGURATION_create (); 74 p->cfg = GNUNET_CONFIGURATION_create ();
75#if START_ARM 75#if START_ARM
76 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 76 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
77 "gnunet-service-arm", 77 "gnunet-service-arm",
78#if VERBOSE 78#if VERBOSE
79 "-L", "DEBUG", 79 "-L", "DEBUG",
@@ -88,12 +88,14 @@ static void
88stop_arm (struct PeerContext *p) 88stop_arm (struct PeerContext *p)
89{ 89{
90#if START_ARM 90#if START_ARM
91 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 91 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
92 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 92 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
93 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 93 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
94 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 94 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
95 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 95 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
96 "ARM process %u stopped\n", p->arm_pid); 96 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
97 GNUNET_OS_process_close (p->arm_proc);
98 p->arm_proc = NULL;
97#endif 99#endif
98 if (uri_this != NULL) 100 if (uri_this != NULL)
99 GNUNET_FS_uri_destroy (uri_this); 101 GNUNET_FS_uri_destroy (uri_this);
diff --git a/src/fs/test_fs_publish.c b/src/fs/test_fs_publish.c
index f5b835259..4e65e7590 100644
--- a/src/fs/test_fs_publish.c
+++ b/src/fs/test_fs_publish.c
@@ -53,7 +53,7 @@ struct PeerContext
53{ 53{
54 struct GNUNET_CONFIGURATION_Handle *cfg; 54 struct GNUNET_CONFIGURATION_Handle *cfg;
55#if START_ARM 55#if START_ARM
56 pid_t arm_pid; 56 GNUNET_OS_Process *arm_proc;
57#endif 57#endif
58}; 58};
59 59
@@ -184,7 +184,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
184{ 184{
185 p->cfg = GNUNET_CONFIGURATION_create (); 185 p->cfg = GNUNET_CONFIGURATION_create ();
186#if START_ARM 186#if START_ARM
187 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 187 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
188 "gnunet-service-arm", 188 "gnunet-service-arm",
189#if VERBOSE 189#if VERBOSE
190 "-L", "DEBUG", 190 "-L", "DEBUG",
@@ -199,12 +199,14 @@ static void
199stop_arm (struct PeerContext *p) 199stop_arm (struct PeerContext *p)
200{ 200{
201#if START_ARM 201#if START_ARM
202 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 202 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
203 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 203 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
204 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 204 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
205 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 205 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
207 "ARM process %u stopped\n", p->arm_pid); 207 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
208 GNUNET_OS_process_close (p->arm_proc);
209 p->arm_proc = NULL;
208#endif 210#endif
209 GNUNET_CONFIGURATION_destroy (p->cfg); 211 GNUNET_CONFIGURATION_destroy (p->cfg);
210} 212}
diff --git a/src/fs/test_fs_publish_persistence.c b/src/fs/test_fs_publish_persistence.c
index b4b9b58ba..afbee2ec8 100644
--- a/src/fs/test_fs_publish_persistence.c
+++ b/src/fs/test_fs_publish_persistence.c
@@ -52,7 +52,7 @@ struct PeerContext
52{ 52{
53 struct GNUNET_CONFIGURATION_Handle *cfg; 53 struct GNUNET_CONFIGURATION_Handle *cfg;
54#if START_ARM 54#if START_ARM
55 pid_t arm_pid; 55 GNUNET_OS_Process *arm_proc;
56#endif 56#endif
57}; 57};
58 58
@@ -243,7 +243,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
243{ 243{
244 p->cfg = GNUNET_CONFIGURATION_create (); 244 p->cfg = GNUNET_CONFIGURATION_create ();
245#if START_ARM 245#if START_ARM
246 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 246 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
247 "gnunet-service-arm", 247 "gnunet-service-arm",
248#if VERBOSE 248#if VERBOSE
249 "-L", "DEBUG", 249 "-L", "DEBUG",
@@ -258,12 +258,14 @@ static void
258stop_arm (struct PeerContext *p) 258stop_arm (struct PeerContext *p)
259{ 259{
260#if START_ARM 260#if START_ARM
261 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 261 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
262 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 262 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
263 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 263 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
264 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 264 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
265 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 265 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
266 "ARM process %u stopped\n", p->arm_pid); 266 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
267 GNUNET_OS_process_close (p->arm_proc);
268 p->arm_proc = NULL;
267#endif 269#endif
268 GNUNET_CONFIGURATION_destroy (p->cfg); 270 GNUNET_CONFIGURATION_destroy (p->cfg);
269} 271}
diff --git a/src/fs/test_fs_search.c b/src/fs/test_fs_search.c
index 98315ac5c..515730689 100644
--- a/src/fs/test_fs_search.c
+++ b/src/fs/test_fs_search.c
@@ -53,7 +53,7 @@ struct PeerContext
53 struct GNUNET_CONFIGURATION_Handle *cfg; 53 struct GNUNET_CONFIGURATION_Handle *cfg;
54 struct GNUNET_PeerIdentity id; 54 struct GNUNET_PeerIdentity id;
55#if START_ARM 55#if START_ARM
56 pid_t arm_pid; 56 GNUNET_OS_Process *arm_proc;
57#endif 57#endif
58}; 58};
59 59
@@ -191,7 +191,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
191{ 191{
192 p->cfg = GNUNET_CONFIGURATION_create (); 192 p->cfg = GNUNET_CONFIGURATION_create ();
193#if START_ARM 193#if START_ARM
194 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 194 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
195 "gnunet-service-arm", 195 "gnunet-service-arm",
196#if VERBOSE 196#if VERBOSE
197 "-L", "DEBUG", 197 "-L", "DEBUG",
@@ -206,12 +206,14 @@ static void
206stop_arm (struct PeerContext *p) 206stop_arm (struct PeerContext *p)
207{ 207{
208#if START_ARM 208#if START_ARM
209 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 209 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
210 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 210 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
211 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 211 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
212 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 212 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
214 "ARM process %u stopped\n", p->arm_pid); 214 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
215 GNUNET_OS_process_close (p->arm_proc);
216 p->arm_proc = NULL;
215#endif 217#endif
216 GNUNET_CONFIGURATION_destroy (p->cfg); 218 GNUNET_CONFIGURATION_destroy (p->cfg);
217} 219}
diff --git a/src/fs/test_fs_search_persistence.c b/src/fs/test_fs_search_persistence.c
index 97b7f656b..c2af22de4 100644
--- a/src/fs/test_fs_search_persistence.c
+++ b/src/fs/test_fs_search_persistence.c
@@ -53,7 +53,7 @@ struct PeerContext
53 struct GNUNET_CONFIGURATION_Handle *cfg; 53 struct GNUNET_CONFIGURATION_Handle *cfg;
54 struct GNUNET_PeerIdentity id; 54 struct GNUNET_PeerIdentity id;
55#if START_ARM 55#if START_ARM
56 pid_t arm_pid; 56 GNUNET_OS_Process *arm_proc;
57#endif 57#endif
58}; 58};
59 59
@@ -262,7 +262,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
262{ 262{
263 p->cfg = GNUNET_CONFIGURATION_create (); 263 p->cfg = GNUNET_CONFIGURATION_create ();
264#if START_ARM 264#if START_ARM
265 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 265 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
266 "gnunet-service-arm", 266 "gnunet-service-arm",
267#if VERBOSE 267#if VERBOSE
268 "-L", "DEBUG", 268 "-L", "DEBUG",
@@ -277,12 +277,14 @@ static void
277stop_arm (struct PeerContext *p) 277stop_arm (struct PeerContext *p)
278{ 278{
279#if START_ARM 279#if START_ARM
280 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 280 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
281 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 281 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
282 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 282 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
283 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 283 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 284 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
285 "ARM process %u stopped\n", p->arm_pid); 285 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
286 GNUNET_OS_process_close (p->arm_proc);
287 p->arm_proc = NULL;
286#endif 288#endif
287 GNUNET_CONFIGURATION_destroy (p->cfg); 289 GNUNET_CONFIGURATION_destroy (p->cfg);
288} 290}
diff --git a/src/fs/test_fs_search_ranking.c b/src/fs/test_fs_search_ranking.c
index 8c75bc1b1..06a069a32 100644
--- a/src/fs/test_fs_search_ranking.c
+++ b/src/fs/test_fs_search_ranking.c
@@ -126,7 +126,7 @@ int
126main (int argc, char *argv[]) 126main (int argc, char *argv[])
127{ 127{
128#if START_DAEMON 128#if START_DAEMON
129 pid_t daemon; 129 GNUNET_OS_Process *daemon;
130#endif 130#endif
131 int ok; 131 int ok;
132 char *fn = NULL; 132 char *fn = NULL;
@@ -153,7 +153,7 @@ main (int argc, char *argv[])
153#if START_DAEMON 153#if START_DAEMON
154 GNUNET_disk_directory_remove (NULL, "/tmp/gnunet-fsui-searchranktest/"); 154 GNUNET_disk_directory_remove (NULL, "/tmp/gnunet-fsui-searchranktest/");
155 daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO); 155 daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
156 GNUNET_GE_ASSERT (NULL, daemon > 0); 156 GNUNET_GE_ASSERT (NULL, daemon != NULL);
157 CHECK (GNUNET_OK == 157 CHECK (GNUNET_OK ==
158 GNUNET_wait_for_daemon_running (NULL, cfg, 158 GNUNET_wait_for_daemon_running (NULL, cfg,
159 30 * GNUNET_CRON_SECONDS)); 159 30 * GNUNET_CRON_SECONDS));
@@ -242,6 +242,8 @@ FAILURE:
242 242
243#if START_DAEMON 243#if START_DAEMON
244 GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon)); 244 GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
245 GNUNET_OS_process_close (daemon);
246 daemon = NULL;
245#endif 247#endif
246 GNUNET_GC_free (cfg); 248 GNUNET_GC_free (cfg);
247 return (ok == GNUNET_YES) ? 0 : 1; 249 return (ok == GNUNET_YES) ? 0 : 1;
diff --git a/src/fs/test_fs_start_stop.c b/src/fs/test_fs_start_stop.c
index 7558ac46a..22fb64ae7 100644
--- a/src/fs/test_fs_start_stop.c
+++ b/src/fs/test_fs_start_stop.c
@@ -41,7 +41,7 @@ struct PeerContext
41{ 41{
42 struct GNUNET_CONFIGURATION_Handle *cfg; 42 struct GNUNET_CONFIGURATION_Handle *cfg;
43#if START_ARM 43#if START_ARM
44 pid_t arm_pid; 44 GNUNET_OS_Process *arm_proc;
45#endif 45#endif
46}; 46};
47 47
@@ -59,7 +59,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
59{ 59{
60 p->cfg = GNUNET_CONFIGURATION_create (); 60 p->cfg = GNUNET_CONFIGURATION_create ();
61#if START_ARM 61#if START_ARM
62 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 62 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
63 "gnunet-service-arm", 63 "gnunet-service-arm",
64#if VERBOSE 64#if VERBOSE
65 "-L", "DEBUG", 65 "-L", "DEBUG",
@@ -74,12 +74,14 @@ static void
74stop_arm (struct PeerContext *p) 74stop_arm (struct PeerContext *p)
75{ 75{
76#if START_ARM 76#if START_ARM
77 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 77 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
78 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 78 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
79 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 79 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
80 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 80 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
81 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 81 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
82 "ARM process %u stopped\n", p->arm_pid); 82 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
83 GNUNET_OS_process_close (p->arm_proc);
84 p->arm_proc = NULL;
83#endif 85#endif
84 GNUNET_CONFIGURATION_destroy (p->cfg); 86 GNUNET_CONFIGURATION_destroy (p->cfg);
85} 87}
diff --git a/src/fs/test_fs_unindex.c b/src/fs/test_fs_unindex.c
index 6fe47a6c4..0afed8f06 100644
--- a/src/fs/test_fs_unindex.c
+++ b/src/fs/test_fs_unindex.c
@@ -52,7 +52,7 @@ struct PeerContext
52{ 52{
53 struct GNUNET_CONFIGURATION_Handle *cfg; 53 struct GNUNET_CONFIGURATION_Handle *cfg;
54#if START_ARM 54#if START_ARM
55 pid_t arm_pid; 55 GNUNET_OS_Process *arm_proc;
56#endif 56#endif
57}; 57};
58 58
@@ -196,7 +196,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
196{ 196{
197 p->cfg = GNUNET_CONFIGURATION_create (); 197 p->cfg = GNUNET_CONFIGURATION_create ();
198#if START_ARM 198#if START_ARM
199 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 199 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
200 "gnunet-service-arm", 200 "gnunet-service-arm",
201#if VERBOSE 201#if VERBOSE
202 "-L", "DEBUG", 202 "-L", "DEBUG",
@@ -211,12 +211,14 @@ static void
211stop_arm (struct PeerContext *p) 211stop_arm (struct PeerContext *p)
212{ 212{
213#if START_ARM 213#if START_ARM
214 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 214 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
215 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 215 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
216 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 216 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
217 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 217 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 218 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
219 "ARM process %u stopped\n", p->arm_pid); 219 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
220 GNUNET_OS_process_close (p->arm_proc);
221 p->arm_proc = NULL;
220#endif 222#endif
221 GNUNET_CONFIGURATION_destroy (p->cfg); 223 GNUNET_CONFIGURATION_destroy (p->cfg);
222} 224}
diff --git a/src/fs/test_fs_unindex_persistence.c b/src/fs/test_fs_unindex_persistence.c
index cbe08913f..d33ecb5fc 100644
--- a/src/fs/test_fs_unindex_persistence.c
+++ b/src/fs/test_fs_unindex_persistence.c
@@ -51,7 +51,7 @@ struct PeerContext
51{ 51{
52 struct GNUNET_CONFIGURATION_Handle *cfg; 52 struct GNUNET_CONFIGURATION_Handle *cfg;
53#if START_ARM 53#if START_ARM
54 pid_t arm_pid; 54 GNUNET_OS_Process *arm_proc;
55#endif 55#endif
56}; 56};
57 57
@@ -266,7 +266,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
266{ 266{
267 p->cfg = GNUNET_CONFIGURATION_create (); 267 p->cfg = GNUNET_CONFIGURATION_create ();
268#if START_ARM 268#if START_ARM
269 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 269 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
270 "gnunet-service-arm", 270 "gnunet-service-arm",
271#if VERBOSE 271#if VERBOSE
272 "-L", "DEBUG", 272 "-L", "DEBUG",
@@ -281,12 +281,14 @@ static void
281stop_arm (struct PeerContext *p) 281stop_arm (struct PeerContext *p)
282{ 282{
283#if START_ARM 283#if START_ARM
284 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 284 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
285 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 285 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
286 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 286 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
287 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 287 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
288 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 288 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
289 "ARM process %u stopped\n", p->arm_pid); 289 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
290 GNUNET_OS_process_close (p->arm_proc);
291 p->arm_proc = NULL;
290#endif 292#endif
291 GNUNET_CONFIGURATION_destroy (p->cfg); 293 GNUNET_CONFIGURATION_destroy (p->cfg);
292} 294}
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c
index 899a2eb44..a13f58a65 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist.c
@@ -49,7 +49,7 @@ struct PeerContext
49 struct GNUNET_TRANSPORT_Handle *th; 49 struct GNUNET_TRANSPORT_Handle *th;
50 struct GNUNET_MessageHeader *hello; 50 struct GNUNET_MessageHeader *hello;
51#if START_ARM 51#if START_ARM
52 pid_t arm_pid; 52 GNUNET_OS_Process *arm_proc;
53#endif 53#endif
54}; 54};
55 55
@@ -135,7 +135,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
135{ 135{
136 p->cfg = GNUNET_CONFIGURATION_create (); 136 p->cfg = GNUNET_CONFIGURATION_create ();
137#if START_ARM 137#if START_ARM
138 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 138 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
139 "gnunet-service-arm", 139 "gnunet-service-arm",
140#if VERBOSE 140#if VERBOSE
141 "-L", "DEBUG", 141 "-L", "DEBUG",
@@ -159,12 +159,14 @@ waitpid_task (void *cls,
159#if START_ARM 159#if START_ARM
160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 160 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
161 "Killing ARM process.\n"); 161 "Killing ARM process.\n");
162 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 162 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
163 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 163 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
164 if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK) 164 if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
165 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 165 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
166 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 166 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
167 "ARM process %u stopped\n", p->arm_pid); 167 "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
168 GNUNET_OS_process_close (p->arm_proc);
169 p->arm_proc = NULL;
168#endif 170#endif
169 GNUNET_CONFIGURATION_destroy (p->cfg); 171 GNUNET_CONFIGURATION_destroy (p->cfg);
170} 172}
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
index 7fd291375..b5e6ca0bf 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
@@ -71,7 +71,7 @@ struct PeerContext
71 struct GNUNET_CORE_Handle *core; 71 struct GNUNET_CORE_Handle *core;
72 struct GNUNET_STATISTICS_Handle *stats; 72 struct GNUNET_STATISTICS_Handle *stats;
73#if START_ARM 73#if START_ARM
74 pid_t arm_pid; 74 GNUNET_OS_Process *arm_proc;
75#endif 75#endif
76}; 76};
77 77
@@ -144,24 +144,28 @@ static void shutdown_testcase()
144#if START_ARM 144#if START_ARM
145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 145 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
146 "Killing hostlist server ARM process.\n"); 146 "Killing hostlist server ARM process.\n");
147 if (0 != PLIBC_KILL (adv_peer.arm_pid, SIGTERM)) 147 if (0 != GNUNET_OS_process_kill (adv_peer.arm_proc, SIGTERM))
148 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 148 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
149 if (GNUNET_OS_process_wait(adv_peer.arm_pid) != GNUNET_OK) 149 if (GNUNET_OS_process_wait(adv_peer.arm_proc) != GNUNET_OK)
150 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 150 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 151 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
152 "Hostlist server ARM process %u stopped\n", adv_peer.arm_pid); 152 "Hostlist server ARM process %u stopped\n", GNUNET_OS_process_get_pid (adv_peer.arm_proc));
153 GNUNET_OS_process_close (adv_peer->arm_proc);
154 adv_peer->arm_proc = NULL;
153#endif 155#endif
154 156
155 157
156#if START_ARM 158#if START_ARM
157 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
158 "Killing hostlist client ARM process.\n"); 160 "Killing hostlist client ARM process.\n");
159 if (0 != PLIBC_KILL (learn_peer.arm_pid, SIGTERM)) 161 if (0 != GNUNET_OS_process_kill (learn_peer.arm_proc, SIGTERM))
160 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 162 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
161 if (GNUNET_OS_process_wait(learn_peer.arm_pid) != GNUNET_OK) 163 if (GNUNET_OS_process_wait(learn_peer.arm_proc) != GNUNET_OK)
162 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 164 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
163 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 165 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
164 "Hostlist client ARM process %u stopped\n", learn_peer.arm_pid); 166 "Hostlist client ARM process %u stopped\n", GNUNET_OS_process_get_pid (learn_peer.arm_proc));
167 GNUNET_OS_process_close (learn_peer->arm_proc);
168 learn_peer->arm_proc = NULL;
165#endif 169#endif
166 170
167 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down scheduler\n"); 171 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down scheduler\n");
@@ -354,7 +358,7 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname)
354 unsigned int result; 358 unsigned int result;
355 p->cfg = GNUNET_CONFIGURATION_create (); 359 p->cfg = GNUNET_CONFIGURATION_create ();
356#if START_ARM 360#if START_ARM
357 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 361 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
358 "gnunet-service-arm", 362 "gnunet-service-arm",
359#if VERBOSE 363#if VERBOSE
360 "-L", "DEBUG", 364 "-L", "DEBUG",
@@ -397,7 +401,7 @@ setup_adv_peer (struct PeerContext *p, const char *cfgname)
397 401
398 p->cfg = GNUNET_CONFIGURATION_create (); 402 p->cfg = GNUNET_CONFIGURATION_create ();
399#if START_ARM 403#if START_ARM
400 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 404 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
401 "gnunet-service-arm", 405 "gnunet-service-arm",
402#if VERBOSE 406#if VERBOSE
403 "-L", "DEBUG", 407 "-L", "DEBUG",
diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h
index 701aae593..2152b279c 100644
--- a/src/include/gnunet_os_lib.h
+++ b/src/include/gnunet_os_lib.h
@@ -44,6 +44,11 @@ extern "C"
44#include "gnunet_configuration_lib.h" 44#include "gnunet_configuration_lib.h"
45#include "gnunet_scheduler_lib.h" 45#include "gnunet_scheduler_lib.h"
46 46
47/**
48 * Process information (OS-dependent)
49 */
50typedef struct _GNUNET_OS_Process GNUNET_OS_Process;
51
47 52
48/** 53/**
49 * Possible installation paths to request 54 * Possible installation paths to request
@@ -170,15 +175,93 @@ void GNUNET_OS_network_interfaces_list (GNUNET_OS_NetworkInterfaceProcessor
170#define GNUNET_OS_get_hostname_max_length() 255 175#define GNUNET_OS_get_hostname_max_length() 255
171#endif 176#endif
172 177
178/**
179 * Allocates new process structure
180 *
181 * Should be made internal?
182 *
183 * @return pointer to allocated structure
184 */
185GNUNET_OS_Process *GNUNET_OS_process_alloc ();
186
187
188/**
189 * Get process structure for current process
190 *
191 * The pointer it returns points to static memory location and must not be
192 * deallocated/closed
193 *
194 * @return pointer to the process sturcutre for this process
195 */
196GNUNET_OS_Process *GNUNET_OS_process_current ();
197
198
199/**
200 * Sends @sig to the process
201 *
202 * @param proc pointer to process structure
203 * @param sig signal
204 * @return 0 on success, -1 on error
205 */
206int GNUNET_OS_process_kill (GNUNET_OS_Process *proc, int sig);
207
208/**
209 * Get process ID
210 *
211 * Should be made internal?
212 *
213 * @param proc pointer to process structure
214 * @return process ID
215 */
216pid_t GNUNET_OS_process_get_pid (GNUNET_OS_Process *proc);
217
218/**
219 * Set process ID
220 *
221 * Should be made internal?
222 *
223 * @param proc pointer to process structure
224 * @param pid process ID
225 */
226void GNUNET_OS_process_set_pid (GNUNET_OS_Process *proc, pid_t pid);
227
228#if WINDOWS
229/**
230 * Get process handle
231 *
232 * Should be made internal?
233 *
234 * @param proc pointer to process structure
235 * @return process handle
236 */
237HANDLE GNUNET_OS_process_get_handle (GNUNET_OS_Process *proc);
238
239/**
240 * Set process handle
241 *
242 * Should be made internal?
243 *
244 * @param proc pointer to process structure
245 * @param handle process handle
246 */
247void GNUNET_OS_process_set_handle(GNUNET_OS_Process *proc, HANDLE handle);
248#endif
249
250/**
251 * Cleans up process structure contents (OS-dependent) and deallocates it
252 *
253 * @param proc pointer to process structure
254 */
255void GNUNET_OS_process_close (GNUNET_OS_Process *proc);
173 256
174/** 257/**
175 * Set process priority 258 * Set process priority
176 * 259 *
177 * @param proc id of the process 260 * @param proc pointer to process structure
178 * @param prio priority value 261 * @param prio priority value
179 * @return GNUNET_OK on success, GNUNET_SYSERR on error 262 * @return GNUNET_OK on success, GNUNET_SYSERR on error
180 */ 263 */
181int GNUNET_OS_set_process_priority (pid_t proc, 264int GNUNET_OS_set_process_priority (GNUNET_OS_Process *proc,
182 enum GNUNET_SCHEDULER_Priority prio); 265 enum GNUNET_SCHEDULER_Priority prio);
183 266
184 267
@@ -189,9 +272,9 @@ int GNUNET_OS_set_process_priority (pid_t proc,
189 * @param pipe_stdout pipe to use to get output from child process (or NULL) 272 * @param pipe_stdout pipe to use to get output from child process (or NULL)
190 * @param filename name of the binary 273 * @param filename name of the binary
191 * @param ... NULL-terminated list of arguments to the process 274 * @param ... NULL-terminated list of arguments to the process
192 * @return process ID of the new process, -1 on error 275 * @return pointer to process structure of the new process, NULL on error
193 */ 276 */
194pid_t 277GNUNET_OS_Process *
195GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, 278GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
196 struct GNUNET_DISK_PipeHandle *pipe_stdout, 279 struct GNUNET_DISK_PipeHandle *pipe_stdout,
197 const char *filename, ...); 280 const char *filename, ...);
@@ -205,29 +288,30 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
205 * @param filename name of the binary 288 * @param filename name of the binary
206 * @param argv NULL-terminated list of arguments to the process, 289 * @param argv NULL-terminated list of arguments to the process,
207 * including the process name as the first argument 290 * including the process name as the first argument
208 * @return process ID of the new process, -1 on error 291 * @return pointer to process structure of the new process, NULL on error
209 */ 292 */
210pid_t GNUNET_OS_start_process_v (const int *lsocks, 293GNUNET_OS_Process *
211 const char *filename, char *const argv[]); 294GNUNET_OS_start_process_v (const int *lsocks, const char *filename,
295 char *const argv[]);
212 296
213 297
214/** 298/**
215 * Retrieve the status of a process 299 * Retrieve the status of a process
216 * @param proc process ID 300 * @param proc pointer to process structure
217 * @param type status type 301 * @param type status type
218 * @param code return code/signal number 302 * @param code return code/signal number
219 * @return GNUNET_OK on success, GNUNET_NO if the process is still running, GNUNET_SYSERR otherwise 303 * @return GNUNET_OK on success, GNUNET_NO if the process is still running, GNUNET_SYSERR otherwise
220 */ 304 */
221int GNUNET_OS_process_status (pid_t proc, enum GNUNET_OS_ProcessStatusType *type, 305int GNUNET_OS_process_status (GNUNET_OS_Process *proc,
222 unsigned long *code); 306 enum GNUNET_OS_ProcessStatusType *type, unsigned long *code);
223 307
224 308
225/** 309/**
226 * Wait for a process 310 * Wait for a process
227 * @param proc process ID to wait for 311 * @param proc pointer to process structure of the process to wait for
228 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 312 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
229 */ 313 */
230int GNUNET_OS_process_wait (pid_t proc); 314int GNUNET_OS_process_wait (GNUNET_OS_Process *proc);
231 315
232 316
233#if 0 /* keep Emacsens' auto-indent happy */ 317#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/include/gnunet_testing_lib.h b/src/include/gnunet_testing_lib.h
index a377e1d1c..3fee527b8 100644
--- a/src/include/gnunet_testing_lib.h
+++ b/src/include/gnunet_testing_lib.h
@@ -301,7 +301,7 @@ struct GNUNET_TESTING_Daemon
301 /** 301 /**
302 * PID of the process that we started last. 302 * PID of the process that we started last.
303 */ 303 */
304 pid_t pid; 304 GNUNET_OS_Process *proc;
305 305
306 /** 306 /**
307 * In which phase are we during the start of 307 * In which phase are we during the start of
diff --git a/src/monkey/test_gnunet_monkey.c b/src/monkey/test_gnunet_monkey.c
index ba832f137..d1d4155d0 100644
--- a/src/monkey/test_gnunet_monkey.c
+++ b/src/monkey/test_gnunet_monkey.c
@@ -42,9 +42,12 @@
42static int 42static int
43check () 43check ()
44{ 44{
45 GNUNET_OS_start_process (NULL, NULL, "gnunet-monkey", 45 GNUNET_OS_process_close (GNUNET_OS_start_process (NULL, NULL,
46 "gnunet-monkey", 46 "gnunet-monkey",
47 "./bug_null_pointer_exception", NULL); 47 "gnunet-monkey",
48 "./bug_null_pointer_exception",
49 NULL));
50
48 return 0; 51 return 0;
49} 52}
50 53
diff --git a/src/peerinfo/perf_peerinfo_api.c b/src/peerinfo/perf_peerinfo_api.c
index ea21b0fae..eea2eb973 100755
--- a/src/peerinfo/perf_peerinfo_api.c
+++ b/src/peerinfo/perf_peerinfo_api.c
@@ -166,11 +166,11 @@ check ()
166 NULL 166 NULL
167 }; 167 };
168#if START_SERVICE 168#if START_SERVICE
169 pid_t pid; 169 GNUNET_OS_Process *proc;
170 struct GNUNET_GETOPT_CommandLineOption options[] = { 170 struct GNUNET_GETOPT_CommandLineOption options[] = {
171 GNUNET_GETOPT_OPTION_END 171 GNUNET_GETOPT_OPTION_END
172 }; 172 };
173 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", 173 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo",
174 "gnunet-service-peerinfo", 174 "gnunet-service-peerinfo",
175#if DEBUG_PEERINFO 175#if DEBUG_PEERINFO
176 "-L", "DEBUG", 176 "-L", "DEBUG",
@@ -185,12 +185,15 @@ check ()
185 numpeers, 185 numpeers,
186 NUM_REQUESTS * NUM_REQUESTS / 2); 186 NUM_REQUESTS * NUM_REQUESTS / 2);
187#if START_SERVICE 187#if START_SERVICE
188 if (0 != PLIBC_KILL (pid, SIGTERM)) 188 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
189 { 189 {
190 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 190 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
191 ok = 1; 191 ok = 1;
192 } 192 }
193 GNUNET_OS_process_wait(pid); 193 GNUNET_OS_process_wait (proc);
194 GNUNET_OS_process_close (proc);
195 proc = NULL;
196
194#endif 197#endif
195 return ok; 198 return ok;
196} 199}
diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c
index 34655c893..b2e95d767 100644
--- a/src/peerinfo/test_peerinfo_api.c
+++ b/src/peerinfo/test_peerinfo_api.c
@@ -165,7 +165,7 @@ static int
165check () 165check ()
166{ 166{
167 int ok = 3; 167 int ok = 3;
168 pid_t pid; 168 GNUNET_OS_Process *proc;
169 char *const argv[] = { "test-peerinfo-api", 169 char *const argv[] = { "test-peerinfo-api",
170 "-c", 170 "-c",
171 "test_peerinfo_api_data.conf", 171 "test_peerinfo_api_data.conf",
@@ -177,7 +177,7 @@ check ()
177 struct GNUNET_GETOPT_CommandLineOption options[] = { 177 struct GNUNET_GETOPT_CommandLineOption options[] = {
178 GNUNET_GETOPT_OPTION_END 178 GNUNET_GETOPT_OPTION_END
179 }; 179 };
180 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo", 180 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo",
181 "gnunet-service-peerinfo", 181 "gnunet-service-peerinfo",
182#if DEBUG_PEERINFO 182#if DEBUG_PEERINFO
183 "-L", "DEBUG", 183 "-L", "DEBUG",
@@ -186,12 +186,14 @@ check ()
186 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, 186 GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
187 argv, "test-peerinfo-api", "nohelp", 187 argv, "test-peerinfo-api", "nohelp",
188 options, &run, &ok); 188 options, &run, &ok);
189 if (0 != PLIBC_KILL (pid, SIGTERM)) 189 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
190 { 190 {
191 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 191 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
192 ok = 1; 192 ok = 1;
193 } 193 }
194 GNUNET_OS_process_wait(pid); 194 GNUNET_OS_process_wait (proc);
195 GNUNET_OS_process_close (proc);
196 proc = NULL;
195 return ok; 197 return ok;
196} 198}
197 199
diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c
index 5c55a11a6..6a45e3b10 100644
--- a/src/statistics/test_statistics_api.c
+++ b/src/statistics/test_statistics_api.c
@@ -29,7 +29,7 @@
29#include "gnunet_scheduler_lib.h" 29#include "gnunet_scheduler_lib.h"
30#include "gnunet_statistics_service.h" 30#include "gnunet_statistics_service.h"
31 31
32#define DEBUG_STATISTICS GNUNET_NO 32#define DEBUG_STATISTICS GNUNET_YES
33 33
34#define START_SERVICE GNUNET_YES 34#define START_SERVICE GNUNET_YES
35 35
@@ -157,8 +157,8 @@ check ()
157 GNUNET_GETOPT_OPTION_END 157 GNUNET_GETOPT_OPTION_END
158 }; 158 };
159#if START_SERVICE 159#if START_SERVICE
160 pid_t pid; 160 GNUNET_OS_Process *proc;
161 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", 161 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
162 "gnunet-service-statistics", 162 "gnunet-service-statistics",
163#if DEBUG_STATISTICS 163#if DEBUG_STATISTICS
164 "-L", "DEBUG", 164 "-L", "DEBUG",
@@ -168,19 +168,21 @@ check ()
168 GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", 168 GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp",
169 options, &run, &ok); 169 options, &run, &ok);
170#if START_SERVICE 170#if START_SERVICE
171 if (0 != PLIBC_KILL (pid, SIGTERM)) 171 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
172 { 172 {
173 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 173 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
174 ok = 1; 174 ok = 1;
175 } 175 }
176 GNUNET_OS_process_wait(pid); 176 GNUNET_OS_process_wait (proc);
177 GNUNET_OS_process_close (proc);
178 proc = NULL;
177#endif 179#endif
178 if (ok != 0) 180 if (ok != 0)
179 return ok; 181 return ok;
180 ok = 1; 182 ok = 1;
181#if START_SERVICE 183#if START_SERVICE
182 /* restart to check persistence! */ 184 /* restart to check persistence! */
183 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", 185 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
184 "gnunet-service-statistics", 186 "gnunet-service-statistics",
185#if DEBUG_STATISTICS 187#if DEBUG_STATISTICS
186 "-L", "DEBUG", 188 "-L", "DEBUG",
@@ -190,12 +192,14 @@ check ()
190 GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", 192 GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp",
191 options, &run_more, &ok); 193 options, &run_more, &ok);
192#if START_SERVICE 194#if START_SERVICE
193 if (0 != PLIBC_KILL (pid, SIGTERM)) 195 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
194 { 196 {
195 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 197 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
196 ok = 1; 198 ok = 1;
197 } 199 }
198 GNUNET_OS_process_wait(pid); 200 GNUNET_OS_process_wait (proc);
201 GNUNET_OS_process_close (proc);
202 proc = NULL;
199#endif 203#endif
200 return ok; 204 return ok;
201} 205}
diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c
index 289e8f09f..b4e7ae7ab 100644
--- a/src/statistics/test_statistics_api_loop.c
+++ b/src/statistics/test_statistics_api_loop.c
@@ -96,8 +96,8 @@ check ()
96 GNUNET_GETOPT_OPTION_END 96 GNUNET_GETOPT_OPTION_END
97 }; 97 };
98#if START_SERVICE 98#if START_SERVICE
99 pid_t pid; 99 GNUNET_OS_Process *proc;
100 pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics", 100 proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
101 "gnunet-service-statistics", 101 "gnunet-service-statistics",
102#if DEBUG_STATISTICS 102#if DEBUG_STATISTICS
103 "-L", "DEBUG", 103 "-L", "DEBUG",
@@ -107,12 +107,14 @@ check ()
107 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", 107 GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp",
108 options, &run, &ok); 108 options, &run, &ok);
109#if START_SERVICE 109#if START_SERVICE
110 if (0 != PLIBC_KILL (pid, SIGTERM)) 110 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
111 { 111 {
112 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 112 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
113 ok = 1; 113 ok = 1;
114 } 114 }
115 GNUNET_OS_process_wait(pid); 115 GNUNET_OS_process_wait (proc);
116 GNUNET_OS_process_close (proc);
117 proc = NULL;
116#endif 118#endif
117 return ok; 119 return ok;
118} 120}
diff --git a/src/testing/test_testing_topology.c b/src/testing/test_testing_topology.c
index bb1455e60..ed1f2d591 100644
--- a/src/testing/test_testing_topology.c
+++ b/src/testing/test_testing_topology.c
@@ -179,12 +179,14 @@ static void gather_log_data ()
179{ 179{
180 char *peer_number; 180 char *peer_number;
181 char *connect_number; 181 char *connect_number;
182 pid_t mem_process; 182 GNUNET_OS_Process *mem_process;
183 GNUNET_asprintf(&peer_number, "%llu", num_peers); 183 GNUNET_asprintf(&peer_number, "%llu", num_peers);
184 GNUNET_asprintf(&connect_number, "%llu", expected_connections); 184 GNUNET_asprintf(&connect_number, "%llu", expected_connections);
185 mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl", 185 mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl",
186 "memsize.pl", "totals.txt", peer_number, connect_number, NULL); 186 "memsize.pl", "totals.txt", peer_number, connect_number, NULL);
187 GNUNET_OS_process_wait(mem_process); 187 GNUNET_OS_process_wait (mem_process);
188 GNUNET_OS_process_close (mem_process);
189 mem_process = NULL;
188} 190}
189 191
190#endif 192#endif
diff --git a/src/testing/testing.c b/src/testing/testing.c
index 7143ba684..89272f3c2 100644
--- a/src/testing/testing.c
+++ b/src/testing/testing.c
@@ -205,7 +205,7 @@ start_fsm (void *cls,
205 { 205 {
206 case SP_COPYING: 206 case SP_COPYING:
207 /* confirm copying complete */ 207 /* confirm copying complete */
208 if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) 208 if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code))
209 { 209 {
210 if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0) 210 if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0)
211 { 211 {
@@ -264,7 +264,7 @@ start_fsm (void *cls,
264 "gnunet-peerinfo", "gnunet-peerinfo", "-c", d->cfgfile, 264 "gnunet-peerinfo", "gnunet-peerinfo", "-c", d->cfgfile,
265 "-sq"); 265 "-sq");
266#endif 266#endif
267 d->pid = GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo", 267 d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo",
268 "gnunet-peerinfo", 268 "gnunet-peerinfo",
269 "-c", d->cfgfile, 269 "-c", d->cfgfile,
270 "-sq", NULL); 270 "-sq", NULL);
@@ -285,7 +285,7 @@ start_fsm (void *cls,
285#endif 285#endif
286 if (d->ssh_port_str == NULL) 286 if (d->ssh_port_str == NULL)
287 { 287 {
288 d->pid = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", 288 d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh",
289 "ssh", 289 "ssh",
290#if !DEBUG_TESTING 290#if !DEBUG_TESTING
291 "-q", 291 "-q",
@@ -296,7 +296,7 @@ start_fsm (void *cls,
296 } 296 }
297 else 297 else
298 { 298 {
299 d->pid = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh", 299 d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh",
300 "ssh", "-p", d->ssh_port_str, 300 "ssh", "-p", d->ssh_port_str,
301#if !DEBUG_TESTING 301#if !DEBUG_TESTING
302 "-q", 302 "-q",
@@ -308,7 +308,7 @@ start_fsm (void *cls,
308 GNUNET_DISK_pipe_close_end(d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); 308 GNUNET_DISK_pipe_close_end(d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE);
309 GNUNET_free (dst); 309 GNUNET_free (dst);
310 } 310 }
311 if (-1 == d->pid) 311 if (NULL == d->proc)
312 { 312 {
313 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 313 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
314 _("Could not start `%s' process to create hostkey.\n"), 314 _("Could not start `%s' process to create hostkey.\n"),
@@ -378,9 +378,10 @@ start_fsm (void *cls,
378 d->cb = NULL; 378 d->cb = NULL;
379 GNUNET_DISK_pipe_close(d->pipe_stdout); 379 GNUNET_DISK_pipe_close(d->pipe_stdout);
380 d->pipe_stdout = NULL; 380 d->pipe_stdout = NULL;
381 (void) PLIBC_KILL (d->pid, SIGKILL); 381 (void) GNUNET_OS_process_kill (d->proc, SIGKILL);
382 GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->pid)); 382 GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc));
383 d->pid = 0; 383 GNUNET_OS_process_close (d->proc);
384 d->proc = NULL;
384 if (NULL != cb) 385 if (NULL != cb)
385 cb (d->cb_cls, 386 cb (d->cb_cls,
386 NULL, 387 NULL,
@@ -391,9 +392,10 @@ start_fsm (void *cls,
391 } 392 }
392 GNUNET_DISK_pipe_close(d->pipe_stdout); 393 GNUNET_DISK_pipe_close(d->pipe_stdout);
393 d->pipe_stdout = NULL; 394 d->pipe_stdout = NULL;
394 (void) PLIBC_KILL (d->pid, SIGKILL); 395 (void) GNUNET_OS_process_kill (d->proc, SIGKILL);
395 GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->pid)); 396 GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc));
396 d->pid = 0; 397 GNUNET_OS_process_close (d->proc);
398 d->proc = NULL;
397#if DEBUG_TESTING 399#if DEBUG_TESTING
398 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 400 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
399 "Successfully got hostkey!\n"); 401 "Successfully got hostkey!\n");
@@ -439,7 +441,7 @@ start_fsm (void *cls,
439 "-L", "DEBUG", 441 "-L", "DEBUG",
440 "-s"); 442 "-s");
441#endif 443#endif
442 d->pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", 444 d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
443 "gnunet-arm", 445 "gnunet-arm",
444 "-c", d->cfgfile, 446 "-c", d->cfgfile,
445#if DEBUG_TESTING 447#if DEBUG_TESTING
@@ -462,7 +464,7 @@ start_fsm (void *cls,
462#endif 464#endif
463 if (d->ssh_port_str == NULL) 465 if (d->ssh_port_str == NULL)
464 { 466 {
465 d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh", 467 d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh",
466 "ssh", 468 "ssh",
467#if !DEBUG_TESTING 469#if !DEBUG_TESTING
468 "-q", 470 "-q",
@@ -477,7 +479,7 @@ start_fsm (void *cls,
477 else 479 else
478 { 480 {
479 481
480 d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh", 482 d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh",
481 "ssh", "-p", d->ssh_port_str, 483 "ssh", "-p", d->ssh_port_str,
482#if !DEBUG_TESTING 484#if !DEBUG_TESTING
483 "-q", 485 "-q",
@@ -491,7 +493,7 @@ start_fsm (void *cls,
491 } 493 }
492 GNUNET_free (dst); 494 GNUNET_free (dst);
493 } 495 }
494 if (-1 == d->pid) 496 if (NULL == d->proc)
495 { 497 {
496 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 498 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
497 _("Could not start `%s' process to start GNUnet.\n"), 499 _("Could not start `%s' process to start GNUnet.\n"),
@@ -520,7 +522,7 @@ start_fsm (void *cls,
520 &start_fsm, d); 522 &start_fsm, d);
521 break; 523 break;
522 case SP_START_ARMING: 524 case SP_START_ARMING:
523 if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) 525 if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code))
524 { 526 {
525 if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0) 527 if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0)
526 { 528 {
@@ -565,7 +567,7 @@ start_fsm (void *cls,
565 break; 567 break;
566 case SP_SHUTDOWN_START: 568 case SP_SHUTDOWN_START:
567 /* confirm copying complete */ 569 /* confirm copying complete */
568 if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) 570 if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code))
569 { 571 {
570 if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0) 572 if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0)
571 { 573 {
@@ -645,7 +647,7 @@ start_fsm (void *cls,
645 break; 647 break;
646 case SP_CONFIG_UPDATE: 648 case SP_CONFIG_UPDATE:
647 /* confirm copying complete */ 649 /* confirm copying complete */
648 if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code)) 650 if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code))
649 { 651 {
650 if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0) /* FIXME: config update should take timeout parameter! */ 652 if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0) /* FIXME: config update should take timeout parameter! */
651 { 653 {
@@ -856,7 +858,7 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
856 858
857 if (ret->ssh_port_str == NULL) 859 if (ret->ssh_port_str == NULL)
858 { 860 {
859 ret->pid = GNUNET_OS_start_process (NULL, NULL, "scp", 861 ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp",
860 "scp", 862 "scp",
861#if !DEBUG_TESTING 863#if !DEBUG_TESTING
862 "-q", 864 "-q",
@@ -865,7 +867,7 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
865 } 867 }
866 else 868 else
867 { 869 {
868 ret->pid = GNUNET_OS_start_process (NULL, NULL, "scp", 870 ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp",
869 "scp", "-P", ret->ssh_port_str, 871 "scp", "-P", ret->ssh_port_str,
870#if !DEBUG_TESTING 872#if !DEBUG_TESTING
871 "-q", 873 "-q",
@@ -873,7 +875,7 @@ GNUNET_TESTING_daemon_start (struct GNUNET_SCHEDULER_Handle *sched,
873 ret->cfgfile, arg, NULL); 875 ret->cfgfile, arg, NULL);
874 } 876 }
875 GNUNET_free (arg); 877 GNUNET_free (arg);
876 if (-1 == ret->pid) 878 if (NULL == ret->proc)
877 { 879 {
878 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 880 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
879 _ 881 _
@@ -972,7 +974,7 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
972 else 974 else
973 arg = GNUNET_strdup (d->hostname); 975 arg = GNUNET_strdup (d->hostname);
974 976
975 d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", 977 d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
976#if !DEBUG_TESTING 978#if !DEBUG_TESTING
977 "-q", 979 "-q",
978#endif 980#endif
@@ -991,7 +993,7 @@ GNUNET_TESTING_daemon_restart (struct GNUNET_TESTING_Daemon *d,
991 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 993 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
992 "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile); 994 "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
993#endif 995#endif
994 d->pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", 996 d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
995 "gnunet-arm", 997 "gnunet-arm",
996#if DEBUG_TESTING 998#if DEBUG_TESTING
997 "-L", "DEBUG", 999 "-L", "DEBUG",
@@ -1107,7 +1109,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1107 else 1109 else
1108 arg = GNUNET_strdup (d->hostname); 1110 arg = GNUNET_strdup (d->hostname);
1109 1111
1110 d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh", 1112 d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
1111#if !DEBUG_TESTING 1113#if !DEBUG_TESTING
1112 "-q", 1114 "-q",
1113#endif 1115#endif
@@ -1127,7 +1129,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
1127 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1129 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1128 "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile); 1130 "Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
1129#endif 1131#endif
1130 d->pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm", 1132 d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
1131 "gnunet-arm", 1133 "gnunet-arm",
1132#if DEBUG_TESTING 1134#if DEBUG_TESTING
1133 "-L", "DEBUG", 1135 "-L", "DEBUG",
@@ -1194,13 +1196,13 @@ GNUNET_TESTING_daemon_reconfigure (struct GNUNET_TESTING_Daemon *d,
1194 GNUNET_asprintf (&arg, "%s@%s:%s", d->username, d->hostname, d->cfgfile); 1196 GNUNET_asprintf (&arg, "%s@%s:%s", d->username, d->hostname, d->cfgfile);
1195 else 1197 else
1196 GNUNET_asprintf (&arg, "%s:%s", d->hostname, d->cfgfile); 1198 GNUNET_asprintf (&arg, "%s:%s", d->hostname, d->cfgfile);
1197 d->pid = GNUNET_OS_start_process (NULL, NULL, "scp", "scp", 1199 d->proc = GNUNET_OS_start_process (NULL, NULL, "scp", "scp",
1198#if !DEBUG_TESTING 1200#if !DEBUG_TESTING
1199 "-q", 1201 "-q",
1200#endif 1202#endif
1201 d->cfgfile, arg, NULL); 1203 d->cfgfile, arg, NULL);
1202 GNUNET_free (arg); 1204 GNUNET_free (arg);
1203 if (-1 == d->pid) 1205 if (NULL == d->proc)
1204 { 1206 {
1205 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 1207 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
1206 _ 1208 _
diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c
index 4c123a980..4b34a21de 100644
--- a/src/testing/testing_group.c
+++ b/src/testing/testing_group.c
@@ -1937,7 +1937,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
1937 FILE *temp_friend_handle; 1937 FILE *temp_friend_handle;
1938 unsigned int pg_iter; 1938 unsigned int pg_iter;
1939 char *temp_service_path; 1939 char *temp_service_path;
1940 pid_t *pidarr; 1940 GNUNET_OS_Process **procarr;
1941 char *arg; 1941 char *arg;
1942 char * mytemp; 1942 char * mytemp;
1943 enum GNUNET_OS_ProcessStatusType type; 1943 enum GNUNET_OS_ProcessStatusType type;
@@ -1946,7 +1946,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
1946 int ret; 1946 int ret;
1947 int max_wait = 10; 1947 int max_wait = 10;
1948 1948
1949 pidarr = GNUNET_malloc(sizeof(pid_t) * pg->total); 1949 procarr = GNUNET_malloc(sizeof(GNUNET_OS_Process *) * pg->total);
1950 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 1950 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
1951 { 1951 {
1952 mytemp = GNUNET_DISK_mktemp("friends"); 1952 mytemp = GNUNET_DISK_mktemp("friends");
@@ -1972,7 +1972,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
1972 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ 1972 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
1973 { 1973 {
1974 GNUNET_asprintf (&arg, "%s/friends", temp_service_path); 1974 GNUNET_asprintf (&arg, "%s/friends", temp_service_path);
1975 pidarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv", 1975 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv",
1976 "mv", mytemp, arg, NULL); 1976 "mv", mytemp, arg, NULL);
1977#if VERBOSE_TESTING 1977#if VERBOSE_TESTING
1978 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1978 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1987,7 +1987,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
1987 GNUNET_asprintf (&arg, "%s@%s:%s/friends", pg->peers[pg_iter].daemon->username, pg->peers[pg_iter].daemon->hostname, temp_service_path); 1987 GNUNET_asprintf (&arg, "%s@%s:%s/friends", pg->peers[pg_iter].daemon->username, pg->peers[pg_iter].daemon->hostname, temp_service_path);
1988 else 1988 else
1989 GNUNET_asprintf (&arg, "%s:%s/friends", pg->peers[pg_iter].daemon->hostname, temp_service_path); 1989 GNUNET_asprintf (&arg, "%s:%s/friends", pg->peers[pg_iter].daemon->hostname, temp_service_path);
1990 pidarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp", 1990 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp",
1991 "scp", mytemp, arg, NULL); 1991 "scp", mytemp, arg, NULL);
1992 1992
1993#if VERBOSE_TESTING 1993#if VERBOSE_TESTING
@@ -2011,9 +2011,9 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2011 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2011 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2012 _("Checking copy status of file %d\n"), pg_iter); 2012 _("Checking copy status of file %d\n"), pg_iter);
2013#endif 2013#endif
2014 if (pidarr[pg_iter] != 0) /* Check for already completed! */ 2014 if (procarr[pg_iter] != NULL) /* Check for already completed! */
2015 { 2015 {
2016 if (GNUNET_OS_process_status(pidarr[pg_iter], &type, &return_code) != GNUNET_OK) 2016 if (GNUNET_OS_process_status(procarr[pg_iter], &type, &return_code) != GNUNET_OK)
2017 { 2017 {
2018 ret = GNUNET_SYSERR; 2018 ret = GNUNET_SYSERR;
2019 } 2019 }
@@ -2023,7 +2023,8 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2023 } 2023 }
2024 else 2024 else
2025 { 2025 {
2026 pidarr[pg_iter] = 0; 2026 GNUNET_OS_process_close (procarr[pg_iter]);
2027 procarr[pg_iter] = NULL;
2027#if VERBOSE_TESTING 2028#if VERBOSE_TESTING
2028 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2029 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2029 _("File %d copied\n"), pg_iter); 2030 _("File %d copied\n"), pg_iter);
@@ -2043,7 +2044,7 @@ create_and_copy_friend_files (struct GNUNET_TESTING_PeerGroup *pg)
2043 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2044 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2044 _("Finished copying all friend files!\n")); 2045 _("Finished copying all friend files!\n"));
2045#endif 2046#endif
2046 GNUNET_free(pidarr); 2047 GNUNET_free(procarr);
2047 return ret; 2048 return ret;
2048} 2049}
2049 2050
@@ -2063,7 +2064,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, const char
2063 static struct BlacklistContext blacklist_ctx; 2064 static struct BlacklistContext blacklist_ctx;
2064 unsigned int pg_iter; 2065 unsigned int pg_iter;
2065 char *temp_service_path; 2066 char *temp_service_path;
2066 pid_t *pidarr; 2067 GNUNET_OS_Process **procarr;
2067 char *arg; 2068 char *arg;
2068 char *mytemp; 2069 char *mytemp;
2069 enum GNUNET_OS_ProcessStatusType type; 2070 enum GNUNET_OS_ProcessStatusType type;
@@ -2076,7 +2077,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, const char
2076 char *pos; 2077 char *pos;
2077 char *temp_transports; 2078 char *temp_transports;
2078 2079
2079 pidarr = GNUNET_malloc(sizeof(pid_t) * pg->total); 2080 procarr = GNUNET_malloc(sizeof(GNUNET_OS_Process *) * pg->total);
2080 for (pg_iter = 0; pg_iter < pg->total; pg_iter++) 2081 for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
2081 { 2082 {
2082 mytemp = GNUNET_DISK_mktemp("blacklist"); 2083 mytemp = GNUNET_DISK_mktemp("blacklist");
@@ -2124,7 +2125,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, const char
2124 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */ 2125 if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
2125 { 2126 {
2126 GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path); 2127 GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path);
2127 pidarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv", 2128 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv",
2128 "mv", mytemp, arg, NULL); 2129 "mv", mytemp, arg, NULL);
2129#if VERBOSE_TESTING 2130#if VERBOSE_TESTING
2130 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2131 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2139,7 +2140,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, const char
2139 GNUNET_asprintf (&arg, "%s@%s:%s/blacklist", pg->peers[pg_iter].daemon->username, pg->peers[pg_iter].daemon->hostname, temp_service_path); 2140 GNUNET_asprintf (&arg, "%s@%s:%s/blacklist", pg->peers[pg_iter].daemon->username, pg->peers[pg_iter].daemon->hostname, temp_service_path);
2140 else 2141 else
2141 GNUNET_asprintf (&arg, "%s:%s/blacklist", pg->peers[pg_iter].daemon->hostname, temp_service_path); 2142 GNUNET_asprintf (&arg, "%s:%s/blacklist", pg->peers[pg_iter].daemon->hostname, temp_service_path);
2142 pidarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp", 2143 procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp",
2143 "scp", mytemp, arg, NULL); 2144 "scp", mytemp, arg, NULL);
2144 2145
2145#if VERBOSE_TESTING 2146#if VERBOSE_TESTING
@@ -2163,9 +2164,9 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, const char
2163 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2164 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2164 _("Checking copy status of file %d\n"), pg_iter); 2165 _("Checking copy status of file %d\n"), pg_iter);
2165#endif 2166#endif
2166 if (pidarr[pg_iter] != 0) /* Check for already completed! */ 2167 if (procarr[pg_iter] != NULL) /* Check for already completed! */
2167 { 2168 {
2168 if (GNUNET_OS_process_status(pidarr[pg_iter], &type, &return_code) != GNUNET_OK) 2169 if (GNUNET_OS_process_status(procarr[pg_iter], &type, &return_code) != GNUNET_OK)
2169 { 2170 {
2170 ret = GNUNET_SYSERR; 2171 ret = GNUNET_SYSERR;
2171 } 2172 }
@@ -2175,7 +2176,8 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, const char
2175 } 2176 }
2176 else 2177 else
2177 { 2178 {
2178 pidarr[pg_iter] = 0; 2179 GNUNET_OS_process_close (procarr[pg_iter]);
2180 procarr[pg_iter] = NULL;
2179#if VERBOSE_TESTING 2181#if VERBOSE_TESTING
2180 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2182 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2181 _("File %d copied\n"), pg_iter); 2183 _("File %d copied\n"), pg_iter);
@@ -2195,7 +2197,7 @@ create_and_copy_blacklist_files (struct GNUNET_TESTING_PeerGroup *pg, const char
2195 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2197 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2196 _("Finished copying all blacklist files!\n")); 2198 _("Finished copying all blacklist files!\n"));
2197#endif 2199#endif
2198 GNUNET_free(pidarr); 2200 GNUNET_free(procarr);
2199 return ret; 2201 return ret;
2200} 2202}
2201 2203
diff --git a/src/transport/plugin_transport_tcp.c b/src/transport/plugin_transport_tcp.c
index 7ac31ecb6..d39787900 100644
--- a/src/transport/plugin_transport_tcp.c
+++ b/src/transport/plugin_transport_tcp.c
@@ -345,7 +345,7 @@ struct Plugin
345 /** 345 /**
346 * The process id of the server process (if behind NAT) 346 * The process id of the server process (if behind NAT)
347 */ 347 */
348 pid_t server_pid; 348 GNUNET_OS_Process *server_proc;
349 349
350 /** 350 /**
351 * List of open TCP sessions. 351 * List of open TCP sessions.
@@ -958,7 +958,7 @@ run_gnunet_nat_client (struct Plugin *plugin, const char *addr, size_t addrlen)
958 char inet4[INET_ADDRSTRLEN]; 958 char inet4[INET_ADDRSTRLEN];
959 char *address_as_string; 959 char *address_as_string;
960 char *port_as_string; 960 char *port_as_string;
961 pid_t pid; 961 GNUNET_OS_Process *proc;
962 const struct sockaddr *sa = (const struct sockaddr *)addr; 962 const struct sockaddr *sa = (const struct sockaddr *)addr;
963 963
964#if DEBUG_TCP_NAT 964#if DEBUG_TCP_NAT
@@ -995,10 +995,12 @@ run_gnunet_nat_client (struct Plugin *plugin, const char *addr, size_t addrlen)
995#endif 995#endif
996 996
997 /* Start the client process */ 997 /* Start the client process */
998 pid = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL); 998 proc = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL);
999 GNUNET_free(address_as_string); 999 GNUNET_free(address_as_string);
1000 GNUNET_free(port_as_string); 1000 GNUNET_free(port_as_string);
1001 GNUNET_OS_process_wait (pid); 1001 GNUNET_OS_process_wait (proc);
1002 GNUNET_OS_process_close (proc);
1003 proc = NULL;
1002} 1004}
1003 1005
1004 1006
@@ -2201,8 +2203,8 @@ tcp_transport_start_nat_server(struct Plugin *plugin)
2201 "Starting gnunet-nat-server process cmd: %s %s\n", "gnunet-nat-server", plugin->internal_address); 2203 "Starting gnunet-nat-server process cmd: %s %s\n", "gnunet-nat-server", plugin->internal_address);
2202#endif 2204#endif
2203 /* Start the server process */ 2205 /* Start the server process */
2204 plugin->server_pid = GNUNET_OS_start_process(NULL, plugin->server_stdout, "gnunet-nat-server", "gnunet-nat-server", plugin->internal_address, NULL); 2206 plugin->server_proc = GNUNET_OS_start_process(NULL, plugin->server_stdout, "gnunet-nat-server", "gnunet-nat-server", plugin->internal_address, NULL);
2205 if (plugin->server_pid == GNUNET_SYSERR) 2207 if (plugin->server_proc == NULL)
2206 { 2208 {
2207#if DEBUG_TCP_NAT 2209#if DEBUG_TCP_NAT
2208 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 2210 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -2603,9 +2605,11 @@ libgnunet_plugin_transport_tcp_done (void *cls)
2603 2605
2604 if (plugin->behind_nat == GNUNET_YES) 2606 if (plugin->behind_nat == GNUNET_YES)
2605 { 2607 {
2606 if (0 != PLIBC_KILL (plugin->server_pid, SIGTERM)) 2608 if (0 != GNUNET_OS_process_kill (plugin->server_proc, SIGTERM))
2607 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 2609 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
2608 GNUNET_OS_process_wait (plugin->server_pid); 2610 GNUNET_OS_process_wait (plugin->server_proc);
2611 GNUNET_OS_process_close (plugin->server_proc);
2612 plugin->server_proc = NULL;
2609 } 2613 }
2610 GNUNET_free_non_null(plugin->bind_address); 2614 GNUNET_free_non_null(plugin->bind_address);
2611 GNUNET_free (plugin); 2615 GNUNET_free (plugin);
diff --git a/src/transport/plugin_transport_udp.c b/src/transport/plugin_transport_udp.c
index 1f7aca59a..0f53719fe 100644
--- a/src/transport/plugin_transport_udp.c
+++ b/src/transport/plugin_transport_udp.c
@@ -471,7 +471,7 @@ struct Plugin
471 /** 471 /**
472 * The process id of the server process (if behind NAT) 472 * The process id of the server process (if behind NAT)
473 */ 473 */
474 pid_t server_pid; 474 GNUNET_OS_Process *server_proc;
475 475
476}; 476};
477 477
@@ -528,9 +528,11 @@ udp_transport_server_stop (void *cls)
528 } 528 }
529 if (plugin->behind_nat == GNUNET_YES) 529 if (plugin->behind_nat == GNUNET_YES)
530 { 530 {
531 if (0 != PLIBC_KILL (plugin->server_pid, SIGTERM)) 531 if (0 != GNUNET_OS_process_kill (plugin->server_proc, SIGTERM))
532 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 532 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
533 GNUNET_OS_process_wait (plugin->server_pid); 533 GNUNET_OS_process_wait (plugin->server_proc);
534 GNUNET_OS_process_close (plugin->server_proc);
535 plugin->server_proc = NULL;
534 } 536 }
535 return GNUNET_OK; 537 return GNUNET_OK;
536} 538}
@@ -700,7 +702,7 @@ run_gnunet_nat_client (struct Plugin *plugin, const char *addr, size_t addrlen)
700 char addr_buf[INET_ADDRSTRLEN]; 702 char addr_buf[INET_ADDRSTRLEN];
701 char *address_as_string; 703 char *address_as_string;
702 char *port_as_string; 704 char *port_as_string;
703 pid_t pid; 705 GNUNET_OS_Process *proc;
704 const struct IPv4UdpAddress *t4; 706 const struct IPv4UdpAddress *t4;
705 707
706 GNUNET_assert(addrlen == sizeof(struct IPv4UdpAddress)); 708 GNUNET_assert(addrlen == sizeof(struct IPv4UdpAddress));
@@ -721,10 +723,12 @@ run_gnunet_nat_client (struct Plugin *plugin, const char *addr, size_t addrlen)
721#endif 723#endif
722 724
723 /* Start the server process */ 725 /* Start the server process */
724 pid = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL); 726 proc = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL);
725 GNUNET_free(address_as_string); 727 GNUNET_free(address_as_string);
726 GNUNET_free(port_as_string); 728 GNUNET_free(port_as_string);
727 GNUNET_OS_process_wait (pid); 729 GNUNET_OS_process_wait (proc);
730 GNUNET_OS_process_close (proc);
731 proc = NULL;
728} 732}
729 733
730/** 734/**
@@ -1637,12 +1641,12 @@ udp_transport_server_start (void *cls)
1637 plugin->internal_address); 1641 plugin->internal_address);
1638#endif 1642#endif
1639 /* Start the server process */ 1643 /* Start the server process */
1640 plugin->server_pid = GNUNET_OS_start_process(NULL, 1644 plugin->server_proc = GNUNET_OS_start_process(NULL,
1641 plugin->server_stdout, 1645 plugin->server_stdout,
1642 "gnunet-nat-server", 1646 "gnunet-nat-server",
1643 "gnunet-nat-server", 1647 "gnunet-nat-server",
1644 plugin->internal_address, NULL); 1648 plugin->internal_address, NULL);
1645 if (plugin->server_pid == GNUNET_SYSERR) 1649 if (plugin->server_proc == NULL)
1646 { 1650 {
1647#if DEBUG_UDP 1651#if DEBUG_UDP
1648 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1652 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/transport/plugin_transport_wlan.c b/src/transport/plugin_transport_wlan.c
index 54cc3f864..e53e4f3b4 100644
--- a/src/transport/plugin_transport_wlan.c
+++ b/src/transport/plugin_transport_wlan.c
@@ -135,7 +135,7 @@ struct Plugin
135 /** 135 /**
136 * The process id of the server process (if behind NAT) 136 * The process id of the server process (if behind NAT)
137 */ 137 */
138 pid_t server_pid; 138 GNUNET_OS_Process *server_proc;
139 139
140 /** 140 /**
141 * The interface of the wlan card given to us by the user. 141 * The interface of the wlan card given to us by the user.
@@ -1245,8 +1245,8 @@ wlan_transport_start_wlan_helper (struct Plugin *plugin)
1245 "Starting gnunet-wlan-helper process cmd: %s %s\n", "gnunet-wlan-helper", plugin->interface); 1245 "Starting gnunet-wlan-helper process cmd: %s %s\n", "gnunet-wlan-helper", plugin->interface);
1246#endif 1246#endif
1247 /* Start the server process */ 1247 /* Start the server process */
1248 plugin->server_pid = GNUNET_OS_start_process(plugin->server_stdin, plugin->server_stdout, "gnunet-transport-wlan-helper", "gnunet-transport-wlan-helper", plugin->interface, NULL); 1248 plugin->server_proc = GNUNET_OS_start_process(plugin->server_stdin, plugin->server_stdout, "gnunet-transport-wlan-helper", "gnunet-transport-wlan-helper", plugin->interface, NULL);
1249 if (plugin->server_pid == GNUNET_SYSERR) 1249 if (plugin->server_proc == NULL)
1250 { 1250 {
1251#if DEBUG_TCP_NAT 1251#if DEBUG_TCP_NAT
1252 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1252 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
diff --git a/src/transport/test_quota_compliance.c b/src/transport/test_quota_compliance.c
index 4c4a025f2..39319f8d7 100644
--- a/src/transport/test_quota_compliance.c
+++ b/src/transport/test_quota_compliance.c
@@ -65,7 +65,7 @@ struct PeerContext
65 struct GNUNET_TRANSPORT_Handle *th; 65 struct GNUNET_TRANSPORT_Handle *th;
66 struct GNUNET_PeerIdentity id; 66 struct GNUNET_PeerIdentity id;
67#if START_ARM 67#if START_ARM
68 pid_t arm_pid; 68 GNUNET_OS_Process *arm_proc;
69#endif 69#endif
70}; 70};
71 71
@@ -197,9 +197,11 @@ static void
197stop_arm (struct PeerContext *p) 197stop_arm (struct PeerContext *p)
198{ 198{
199#if START_ARM 199#if START_ARM
200 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 200 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
201 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 201 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
202 GNUNET_OS_process_wait (p->arm_pid); 202 GNUNET_OS_process_wait (p->arm_proc);
203 GNUNET_OS_process_close (p->arm_proc);
204 p->arm_proc = NULL;
203#endif 205#endif
204 GNUNET_CONFIGURATION_destroy (p->cfg); 206 GNUNET_CONFIGURATION_destroy (p->cfg);
205} 207}
@@ -576,7 +578,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
576{ 578{
577 p->cfg = GNUNET_CONFIGURATION_create (); 579 p->cfg = GNUNET_CONFIGURATION_create ();
578#if START_ARM 580#if START_ARM
579 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, 581 p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
580 "gnunet-service-arm", 582 "gnunet-service-arm",
581 "gnunet-service-arm", 583 "gnunet-service-arm",
582#if VERBOSE_ARM 584#if VERBOSE_ARM
diff --git a/src/transport/test_transport_api.c b/src/transport/test_transport_api.c
index 789a97f3d..7a45ea0f0 100644
--- a/src/transport/test_transport_api.c
+++ b/src/transport/test_transport_api.c
@@ -60,7 +60,7 @@ struct PeerContext
60 struct GNUNET_TRANSPORT_Handle *th; 60 struct GNUNET_TRANSPORT_Handle *th;
61 struct GNUNET_PeerIdentity id; 61 struct GNUNET_PeerIdentity id;
62#if START_ARM 62#if START_ARM
63 pid_t arm_pid; 63 GNUNET_OS_Process *arm_proc;
64#endif 64#endif
65}; 65};
66 66
@@ -118,9 +118,11 @@ static void
118stop_arm (struct PeerContext *p) 118stop_arm (struct PeerContext *p)
119{ 119{
120#if START_ARM 120#if START_ARM
121 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 121 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
122 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 122 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
123 GNUNET_OS_process_wait (p->arm_pid); 123 GNUNET_OS_process_wait (p->arm_proc);
124 GNUNET_OS_process_close (p->arm_proc);
125 p->arm_proc = NULL;
124#endif 126#endif
125 GNUNET_CONFIGURATION_destroy (p->cfg); 127 GNUNET_CONFIGURATION_destroy (p->cfg);
126} 128}
@@ -220,7 +222,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
220{ 222{
221 p->cfg = GNUNET_CONFIGURATION_create (); 223 p->cfg = GNUNET_CONFIGURATION_create ();
222#if START_ARM 224#if START_ARM
223 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm", 225 p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
224 "gnunet-service-arm", 226 "gnunet-service-arm",
225#if VERBOSE_ARM 227#if VERBOSE_ARM
226 "-L", "DEBUG", 228 "-L", "DEBUG",
diff --git a/src/transport/test_transport_api_reliability.c b/src/transport/test_transport_api_reliability.c
index 0625230a4..d9e88fe49 100644
--- a/src/transport/test_transport_api_reliability.c
+++ b/src/transport/test_transport_api_reliability.c
@@ -62,7 +62,7 @@ struct PeerContext
62 struct GNUNET_TRANSPORT_Handle *th; 62 struct GNUNET_TRANSPORT_Handle *th;
63 struct GNUNET_PeerIdentity id; 63 struct GNUNET_PeerIdentity id;
64#if START_ARM 64#if START_ARM
65 pid_t arm_pid; 65 GNUNET_OS_Process *arm_proc;
66#endif 66#endif
67}; 67};
68 68
@@ -141,9 +141,11 @@ static void
141stop_arm (struct PeerContext *p) 141stop_arm (struct PeerContext *p)
142{ 142{
143#if START_ARM 143#if START_ARM
144 if (0 != PLIBC_KILL (p->arm_pid, SIGTERM)) 144 if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
145 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 145 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
146 GNUNET_OS_process_wait (p->arm_pid); 146 GNUNET_OS_process_wait (p->arm_proc);
147 GNUNET_OS_process_close (p->arm_proc);
148 p->arm_proc = NULL;
147#endif 149#endif
148 GNUNET_CONFIGURATION_destroy (p->cfg); 150 GNUNET_CONFIGURATION_destroy (p->cfg);
149} 151}
@@ -381,7 +383,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
381{ 383{
382 p->cfg = GNUNET_CONFIGURATION_create (); 384 p->cfg = GNUNET_CONFIGURATION_create ();
383#if START_ARM 385#if START_ARM
384 p->arm_pid = GNUNET_OS_start_process (NULL, NULL, 386 p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
385 "gnunet-service-arm", 387 "gnunet-service-arm",
386 "gnunet-service-arm", 388 "gnunet-service-arm",
387#if VERBOSE_ARM 389#if VERBOSE_ARM
diff --git a/src/util/crypto_random.c b/src/util/crypto_random.c
index 4fcb157d9..75435a5e6 100644
--- a/src/util/crypto_random.c
+++ b/src/util/crypto_random.c
@@ -188,7 +188,7 @@ GNUNET_CRYPTO_random_disable_entropy_gathering ()
188 * Process ID of the "find" process that we use for 188 * Process ID of the "find" process that we use for
189 * entropy gathering. 189 * entropy gathering.
190 */ 190 */
191static pid_t genproc; 191static GNUNET_OS_Process *genproc;
192 192
193/** 193/**
194 * Function called by libgcrypt whenever we are 194 * Function called by libgcrypt whenever we are
@@ -206,16 +206,17 @@ entropy_generator (void *cls,
206 return; 206 return;
207 if (current == total) 207 if (current == total)
208 { 208 {
209 if (genproc != 0) 209 if (genproc != NULL)
210 { 210 {
211 if (0 != PLIBC_KILL (genproc, SIGTERM)) 211 if (0 != GNUNET_OS_process_kill (genproc, SIGTERM))
212 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill"); 212 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill");
213 GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc)); 213 GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc));
214 genproc = 0; 214 GNUNET_OS_process_close (genproc);
215 genproc = NULL;
215 } 216 }
216 return; 217 return;
217 } 218 }
218 if (genproc != 0) 219 if (genproc != NULL)
219 { 220 {
220 ret = GNUNET_OS_process_status (genproc, &type, &code); 221 ret = GNUNET_OS_process_status (genproc, &type, &code);
221 if (ret == GNUNET_NO) 222 if (ret == GNUNET_NO)
@@ -225,10 +226,11 @@ entropy_generator (void *cls,
225 GNUNET_break (0); 226 GNUNET_break (0);
226 return; 227 return;
227 } 228 }
228 if (0 != PLIBC_KILL (genproc, SIGTERM)) 229 if (0 != GNUNET_OS_process_kill (genproc, SIGTERM))
229 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill"); 230 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill");
230 GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc)); 231 GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc));
231 genproc = 0; 232 GNUNET_OS_process_close (genproc);
233 genproc = NULL;
232 } 234 }
233 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 235 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
234 _("Starting `%s' process to generate entropy\n"), "find"); 236 _("Starting `%s' process to generate entropy\n"), "find");
@@ -243,10 +245,11 @@ entropy_generator (void *cls,
243static void 245static void
244killfind () 246killfind ()
245{ 247{
246 if (genproc != 0) 248 if (genproc != NULL)
247 { 249 {
248 PLIBC_KILL (genproc, SIGKILL); 250 GNUNET_OS_process_kill (genproc, SIGKILL);
249 genproc = 0; 251 GNUNET_OS_process_close (genproc);
252 genproc = NULL;
250 } 253 }
251} 254}
252 255
@@ -279,3 +282,4 @@ void __attribute__ ((destructor)) GNUNET_CRYPTO_random_fini ()
279 282
280 283
281/* end of crypto_random.c */ 284/* end of crypto_random.c */
285
diff --git a/src/util/os_priority.c b/src/util/os_priority.c
index e2e170cb9..b9e5f010b 100644
--- a/src/util/os_priority.c
+++ b/src/util/os_priority.c
@@ -29,6 +29,112 @@
29#include "gnunet_os_lib.h" 29#include "gnunet_os_lib.h"
30#include "disk.h" 30#include "disk.h"
31 31
32struct _GNUNET_OS_Process
33{
34 pid_t pid;
35#if WINDOWS
36 HANDLE handle;
37#endif
38};
39
40static GNUNET_OS_Process current_process;
41
42GNUNET_OS_Process *
43GNUNET_OS_process_alloc ()
44{
45 GNUNET_OS_Process *ret = GNUNET_malloc (sizeof (GNUNET_OS_Process));
46 ret->pid = 0;
47#if WINDOWS
48 ret->handle = NULL;
49#endif
50 return ret;
51}
52
53/**
54 * Get process structure for current process
55 *
56 * The pointer it returns points to static memory location and must not be
57 * deallocated/closed
58 *
59 * @return pointer to the process sturcutre for this process
60 */
61GNUNET_OS_Process *
62GNUNET_OS_process_current ()
63{
64#if WINDOWS
65 current_process.pid = GetCurrentProcessId ();
66 current_process.handle = GetCurrentProcess ();
67#else
68 current_process.pid = 0;
69#endif
70 return &current_process;
71}
72
73int
74GNUNET_OS_process_kill (GNUNET_OS_Process *proc, int sig)
75{
76#if WINDOWS
77 if (sig == SIGKILL || sig == SIGTERM)
78 {
79 HANDLE h = GNUNET_OS_process_get_handle (proc);
80 if (NULL == h)
81 {
82 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n", GNUNET_OS_process_get_pid (proc), h);
83 return -1;
84 }
85 if (!TerminateProcess (h, 0))
86 {
87 SetErrnoFromWinError (GetLastError ());
88 return -1;
89 }
90 else
91 return 0;
92 }
93 errno = EINVAL;
94 return -1;
95#else
96 return kill (GNUNET_OS_process_get_pid (proc), sig);
97#endif
98}
99
100pid_t
101GNUNET_OS_process_get_pid (GNUNET_OS_Process *proc)
102{
103 return proc->pid;
104}
105
106void
107GNUNET_OS_process_set_pid (GNUNET_OS_Process *proc, pid_t pid)
108{
109 proc->pid = pid;
110}
111
112#if WINDOWS
113HANDLE
114GNUNET_OS_process_get_handle (GNUNET_OS_Process *proc)
115{
116 return proc->handle;
117}
118
119void
120GNUNET_OS_process_set_handle(GNUNET_OS_Process *proc, HANDLE handle)
121{
122 if (proc->handle != NULL)
123 CloseHandle (proc->handle);
124 proc->handle = handle;
125}
126#endif
127
128void
129GNUNET_OS_process_close (GNUNET_OS_Process *proc)
130{
131#if WINDOWS
132 if (proc->handle != NULL)
133 CloseHandle (proc->handle);
134#endif
135 GNUNET_free (proc);
136}
137
32#if WINDOWS 138#if WINDOWS
33#include "gnunet_signal_lib.h" 139#include "gnunet_signal_lib.h"
34 140
@@ -36,17 +142,17 @@ extern GNUNET_SIGNAL_Handler w32_sigchld_handler;
36 142
37/** 143/**
38 * @brief Waits for a process to terminate and invokes the SIGCHLD handler 144 * @brief Waits for a process to terminate and invokes the SIGCHLD handler
39 * @param h handle to the process 145 * @param proc pointer to process structure
40 */ 146 */
41static DWORD WINAPI 147static DWORD WINAPI
42ChildWaitThread (HANDLE h) 148ChildWaitThread (void *arg)
43{ 149{
44 WaitForSingleObject (h, INFINITE); 150 GNUNET_OS_Process *proc = (GNUNET_OS_Process *) arg;
151 WaitForSingleObject (proc->handle, INFINITE);
45 152
46 if (w32_sigchld_handler) 153 if (w32_sigchld_handler)
47 w32_sigchld_handler (); 154 w32_sigchld_handler ();
48 155
49 CloseHandle (h);
50 return 0; 156 return 0;
51} 157}
52#endif 158#endif
@@ -54,19 +160,21 @@ ChildWaitThread (HANDLE h)
54/** 160/**
55 * Set process priority 161 * Set process priority
56 * 162 *
57 * @param proc id of the process 163 * @param proc pointer to process structure
58 * @param prio priority value 164 * @param prio priority value
59 * @return GNUNET_OK on success, GNUNET_SYSERR on error 165 * @return GNUNET_OK on success, GNUNET_SYSERR on error
60 */ 166 */
61int 167int
62GNUNET_OS_set_process_priority (pid_t proc, 168GNUNET_OS_set_process_priority (GNUNET_OS_Process *proc,
63 enum GNUNET_SCHEDULER_Priority prio) 169 enum GNUNET_SCHEDULER_Priority prio)
64{ 170{
65 int rprio; 171 int rprio;
172 pid_t pid;
66 173
67 GNUNET_assert (prio < GNUNET_SCHEDULER_PRIORITY_COUNT); 174 GNUNET_assert (prio < GNUNET_SCHEDULER_PRIORITY_COUNT);
68 if (prio == GNUNET_SCHEDULER_PRIORITY_KEEP) 175 if (prio == GNUNET_SCHEDULER_PRIORITY_KEEP)
69 return GNUNET_OK; 176 return GNUNET_OK;
177
70 /* convert to MINGW/Unix values */ 178 /* convert to MINGW/Unix values */
71 switch (prio) 179 switch (prio)
72 { 180 {
@@ -114,12 +222,19 @@ GNUNET_OS_set_process_priority (pid_t proc,
114 GNUNET_assert (0); 222 GNUNET_assert (0);
115 return GNUNET_SYSERR; 223 return GNUNET_SYSERR;
116 } 224 }
225
226 pid = GNUNET_OS_process_get_pid (proc);
227
117 /* Set process priority */ 228 /* Set process priority */
118#ifdef MINGW 229#ifdef MINGW
119 SetPriorityClass (GetCurrentProcess (), rprio); 230 {
231 HANDLE h = GNUNET_OS_process_get_handle (proc);
232 GNUNET_assert (h != NULL);
233 SetPriorityClass (h, rprio);
234 }
120#elif LINUX 235#elif LINUX
121 if ( (0 == proc) || 236 if ( (0 == pid) ||
122 (proc == getpid () ) ) 237 (pid == getpid () ) )
123 { 238 {
124 int have = nice (0); 239 int have = nice (0);
125 int delta = rprio - have; 240 int delta = rprio - have;
@@ -135,7 +250,7 @@ GNUNET_OS_set_process_priority (pid_t proc,
135 } 250 }
136 else 251 else
137 { 252 {
138 if (0 != setpriority (PRIO_PROCESS, proc, rprio)) 253 if (0 != setpriority (PRIO_PROCESS, pid, rprio))
139 254
140 { 255 {
141 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING | 256 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING |
@@ -157,18 +272,18 @@ GNUNET_OS_set_process_priority (pid_t proc,
157 * @param pipe_stdout pipe to use to get output from child process (or NULL) 272 * @param pipe_stdout pipe to use to get output from child process (or NULL)
158 * @param filename name of the binary 273 * @param filename name of the binary
159 * @param ... NULL-terminated list of arguments to the process 274 * @param ... NULL-terminated list of arguments to the process
160 * @return process ID of the new process, -1 on error 275 * @return pointer to process structure of the new process, NULL on error
161 */ 276 */
162pid_t 277GNUNET_OS_Process *
163GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, 278GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
164 struct GNUNET_DISK_PipeHandle *pipe_stdout, 279 struct GNUNET_DISK_PipeHandle *pipe_stdout,
165 const char *filename, ...) 280 const char *filename, ...)
166{ 281{
167 /* FIXME: Make this work on windows!!! */
168 va_list ap; 282 va_list ap;
169 283
170#ifndef MINGW 284#ifndef MINGW
171 pid_t ret; 285 pid_t ret;
286 GNUNET_OS_Process *gnunet_proc = NULL;
172 char **argv; 287 char **argv;
173 int argc; 288 int argc;
174 int fd_stdout_write; 289 int fd_stdout_write;
@@ -227,9 +342,11 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
227 GNUNET_DISK_pipe_close_end(pipe_stdin, GNUNET_DISK_PIPE_END_READ); 342 GNUNET_DISK_pipe_close_end(pipe_stdin, GNUNET_DISK_PIPE_END_READ);
228 sleep (1); 343 sleep (1);
229#endif 344#endif
345 gnunet_proc = GNUNET_OS_process_alloc ();
346 GNUNET_OS_process_set_pid (gnunet_proc, ret);
230 } 347 }
231 GNUNET_free (argv); 348 GNUNET_free (argv);
232 return ret; 349 return gnunet_proc;
233 } 350 }
234 351
235 if (pipe_stdout != NULL) 352 if (pipe_stdout != NULL)
@@ -258,6 +375,7 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
258 int findresult; 375 int findresult;
259 STARTUPINFO start; 376 STARTUPINFO start;
260 PROCESS_INFORMATION proc; 377 PROCESS_INFORMATION proc;
378 GNUNET_OS_Process *gnunet_proc = NULL;
261 379
262 HANDLE stdin_handle; 380 HANDLE stdin_handle;
263 HANDLE stdout_handle; 381 HANDLE stdout_handle;
@@ -299,7 +417,7 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
299 { 417 {
300 SetErrnoFromWinError (GetLastError ()); 418 SetErrnoFromWinError (GetLastError ());
301 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "FindExecutable", filename); 419 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "FindExecutable", filename);
302 return (pid_t) -1; 420 return NULL;
303 } 421 }
304 422
305 if (!CreateProcessA 423 if (!CreateProcessA
@@ -308,16 +426,20 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
308 { 426 {
309 SetErrnoFromWinError (GetLastError ()); 427 SetErrnoFromWinError (GetLastError ());
310 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "CreateProcess", path); 428 GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "CreateProcess", path);
311 return (pid_t) -1; 429 return NULL;
312 } 430 }
313 431
314 CreateThread (NULL, 64000, ChildWaitThread, proc.hProcess, 0, NULL); 432 gnunet_proc = GNUNET_OS_process_alloc ();
433 GNUNET_OS_process_set_pid (gnunet_proc, proc.dwProcessId);
434 GNUNET_OS_process_set_handle (gnunet_proc, proc.hProcess);
435
436 CreateThread (NULL, 64000, ChildWaitThread, (void *) gnunet_proc, 0, NULL);
315 437
316 CloseHandle (proc.hThread); 438 CloseHandle (proc.hThread);
317 439
318 GNUNET_free (cmd); 440 GNUNET_free (cmd);
319 441
320 return proc.dwProcessId; 442 return gnunet_proc;
321#endif 443#endif
322 444
323} 445}
@@ -333,7 +455,7 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
333 * @param argv NULL-terminated list of arguments to the process 455 * @param argv NULL-terminated list of arguments to the process
334 * @return process ID of the new process, -1 on error 456 * @return process ID of the new process, -1 on error
335 */ 457 */
336pid_t 458GNUNET_OS_Process *
337GNUNET_OS_start_process_v (const int *lsocks, 459GNUNET_OS_start_process_v (const int *lsocks,
338 const char *filename, char *const argv[]) 460 const char *filename, char *const argv[])
339{ 461{
@@ -341,6 +463,7 @@ GNUNET_OS_start_process_v (const int *lsocks,
341 pid_t ret; 463 pid_t ret;
342 char lpid[16]; 464 char lpid[16];
343 char fds[16]; 465 char fds[16];
466 GNUNET_OS_Process *gnunet_proc = NULL;
344 int i; 467 int i;
345 int j; 468 int j;
346 int k; 469 int k;
@@ -382,9 +505,11 @@ GNUNET_OS_start_process_v (const int *lsocks,
382 be plenty in practice */ 505 be plenty in practice */
383 sleep (1); 506 sleep (1);
384#endif 507#endif
508 gnunet_proc = GNUNET_OS_process_alloc ();
509 GNUNET_OS_process_set_pid (gnunet_proc, ret);
385 } 510 }
386 GNUNET_array_grow (lscp, ls, 0); 511 GNUNET_array_grow (lscp, ls, 0);
387 return ret; 512 return gnunet_proc;
388 } 513 }
389 if (lscp != NULL) 514 if (lscp != NULL)
390 { 515 {
@@ -441,6 +566,7 @@ GNUNET_OS_start_process_v (const int *lsocks,
441 int argcount = 0; 566 int argcount = 0;
442 char *non_const_filename = NULL; 567 char *non_const_filename = NULL;
443 int filenamelen = 0; 568 int filenamelen = 0;
569 GNUNET_OS_Process *gnunet_proc = NULL;
444 570
445 GNUNET_assert (lsocks == NULL); 571 GNUNET_assert (lsocks == NULL);
446 /* Count the number of arguments */ 572 /* Count the number of arguments */
@@ -504,11 +630,15 @@ GNUNET_OS_start_process_v (const int *lsocks,
504 &proc)) 630 &proc))
505 { 631 {
506 SetErrnoFromWinError (GetLastError ()); 632 SetErrnoFromWinError (GetLastError ());
507 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "fork"); 633 GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "CreateProcess");
508 return -1; 634 return NULL;
509 } 635 }
510 636
511 CreateThread (NULL, 64000, ChildWaitThread, proc.hProcess, 0, NULL); 637 gnunet_proc = GNUNET_OS_process_alloc ();
638 GNUNET_OS_process_set_pid (gnunet_proc, proc.dwProcessId);
639 GNUNET_OS_process_set_handle (gnunet_proc, proc.hProcess);
640
641 CreateThread (NULL, 64000, ChildWaitThread, (void *) gnunet_proc, 0, NULL);
512 642
513 CloseHandle (proc.hThread); 643 CloseHandle (proc.hThread);
514 GNUNET_free (cmd); 644 GNUNET_free (cmd);
@@ -517,7 +647,7 @@ GNUNET_OS_start_process_v (const int *lsocks,
517 GNUNET_free (non_const_argv[--argcount]); 647 GNUNET_free (non_const_argv[--argcount]);
518 GNUNET_free (non_const_argv); 648 GNUNET_free (non_const_argv);
519 649
520 return proc.dwProcessId; 650 return gnunet_proc;
521#endif 651#endif
522} 652}
523 653
@@ -529,7 +659,7 @@ GNUNET_OS_start_process_v (const int *lsocks,
529 * @return GNUNET_OK on success, GNUNET_NO if the process is still running, GNUNET_SYSERR otherwise 659 * @return GNUNET_OK on success, GNUNET_NO if the process is still running, GNUNET_SYSERR otherwise
530 */ 660 */
531int 661int
532GNUNET_OS_process_status (pid_t proc, enum GNUNET_OS_ProcessStatusType *type, 662GNUNET_OS_process_status (GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type,
533 unsigned long *code) 663 unsigned long *code)
534{ 664{
535#ifndef MINGW 665#ifndef MINGW
@@ -537,7 +667,7 @@ GNUNET_OS_process_status (pid_t proc, enum GNUNET_OS_ProcessStatusType *type,
537 int ret; 667 int ret;
538 668
539 GNUNET_assert (0 != proc); 669 GNUNET_assert (0 != proc);
540 ret = waitpid (proc, &status, WNOHANG); 670 ret = waitpid (GNUNET_OS_process_get_pid (proc), &status, WNOHANG);
541 if (ret < 0) 671 if (ret < 0)
542 { 672 {
543 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 673 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
@@ -549,7 +679,7 @@ GNUNET_OS_process_status (pid_t proc, enum GNUNET_OS_ProcessStatusType *type,
549 *code = 0; 679 *code = 0;
550 return GNUNET_NO; 680 return GNUNET_NO;
551 } 681 }
552 if (proc != ret) 682 if (GNUNET_OS_process_get_pid (proc) != ret)
553 { 683 {
554 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid"); 684 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
555 return GNUNET_SYSERR; 685 return GNUNET_SYSERR;
@@ -583,27 +713,35 @@ GNUNET_OS_process_status (pid_t proc, enum GNUNET_OS_ProcessStatusType *type,
583 } 713 }
584#else 714#else
585 HANDLE h; 715 HANDLE h;
586 DWORD c; 716 DWORD c, error_code, ret;
587 717
588 h = OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, proc); 718 h = GNUNET_OS_process_get_handle (proc);
589 if (INVALID_HANDLE_VALUE == h) 719 ret = GNUNET_OS_process_get_pid (proc);
720 if (h == NULL || ret == 0)
590 { 721 {
591 SetErrnoFromWinError (GetLastError ()); 722 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n", ret, h);
592 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "OpenProcess");
593 return GNUNET_SYSERR; 723 return GNUNET_SYSERR;
594 } 724 }
725 if (h == NULL)
726 h = GetCurrentProcess ();
595 727
596 c = GetExitCodeProcess (h, &c); 728 SetLastError (0);
729 ret = GetExitCodeProcess (h, &c);
730 error_code = GetLastError ();
731 if (ret == 0 || error_code != NO_ERROR)
732 {
733 SetErrnoFromWinError (error_code);
734 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "GetExitCodeProcess");
735 return GNUNET_SYSERR;
736 }
597 if (STILL_ACTIVE == c) 737 if (STILL_ACTIVE == c)
598 { 738 {
599 *type = GNUNET_OS_PROCESS_RUNNING; 739 *type = GNUNET_OS_PROCESS_RUNNING;
600 *code = 0; 740 *code = 0;
601 CloseHandle (h);
602 return GNUNET_NO; 741 return GNUNET_NO;
603 } 742 }
604 *type = GNUNET_OS_PROCESS_EXITED; 743 *type = GNUNET_OS_PROCESS_EXITED;
605 *code = c; 744 *code = c;
606 CloseHandle (h);
607#endif 745#endif
608 746
609 return GNUNET_OK; 747 return GNUNET_OK;
@@ -611,14 +749,15 @@ GNUNET_OS_process_status (pid_t proc, enum GNUNET_OS_ProcessStatusType *type,
611 749
612/** 750/**
613 * Wait for a process 751 * Wait for a process
614 * @param proc process ID to wait for 752 * @param proc pointer to process structure
615 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise 753 * @return GNUNET_OK on success, GNUNET_SYSERR otherwise
616 */ 754 */
617int 755int
618GNUNET_OS_process_wait (pid_t proc) 756GNUNET_OS_process_wait (GNUNET_OS_Process *proc)
619{ 757{
758 pid_t pid = GNUNET_OS_process_get_pid (proc);
620#ifndef MINGW 759#ifndef MINGW
621 if (proc != waitpid (proc, NULL, 0)) 760 if (pid != waitpid (pid, NULL, 0))
622 return GNUNET_SYSERR; 761 return GNUNET_SYSERR;
623 762
624 return GNUNET_OK; 763 return GNUNET_OK;
@@ -626,12 +765,14 @@ GNUNET_OS_process_wait (pid_t proc)
626 HANDLE h; 765 HANDLE h;
627 int ret; 766 int ret;
628 767
629 h = OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, proc); 768 h = GNUNET_OS_process_get_handle (proc);
630 if (INVALID_HANDLE_VALUE == h) 769 if (NULL == h)
631 { 770 {
632 SetErrnoFromWinError (GetLastError ()); 771 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n", pid, h);
633 return GNUNET_SYSERR; 772 return GNUNET_SYSERR;
634 } 773 }
774 if (h == NULL)
775 h = GetCurrentProcess ();
635 776
636 if (WAIT_OBJECT_0 != WaitForSingleObject (h, INFINITE)) 777 if (WAIT_OBJECT_0 != WaitForSingleObject (h, INFINITE))
637 { 778 {
@@ -641,8 +782,6 @@ GNUNET_OS_process_wait (pid_t proc)
641 else 782 else
642 ret = GNUNET_OK; 783 ret = GNUNET_OK;
643 784
644 CloseHandle (h);
645
646 return ret; 785 return ret;
647#endif 786#endif
648} 787}
diff --git a/src/util/scheduler.c b/src/util/scheduler.c
index 67406e21c..35e0a70c9 100644
--- a/src/util/scheduler.c
+++ b/src/util/scheduler.c
@@ -633,7 +633,7 @@ run_ready (struct GNUNET_SCHEDULER_Handle *sched,
633 if (sched->current_priority != pos->priority) 633 if (sched->current_priority != pos->priority)
634 { 634 {
635 sched->current_priority = pos->priority; 635 sched->current_priority = pos->priority;
636 (void) GNUNET_OS_set_process_priority (0, pos->priority); 636 (void) GNUNET_OS_set_process_priority (GNUNET_OS_process_current (), pos->priority);
637 } 637 }
638 sched->active_task = pos; 638 sched->active_task = pos;
639#if PROFILE_DELAYS 639#if PROFILE_DELAYS
diff --git a/src/util/test_os_priority.c b/src/util/test_os_priority.c
index c2fdcc6f5..17874a6ee 100644
--- a/src/util/test_os_priority.c
+++ b/src/util/test_os_priority.c
@@ -32,27 +32,27 @@ testprio ()
32{ 32{
33 pid_t child; 33 pid_t child;
34 if (GNUNET_OK != 34 if (GNUNET_OK !=
35 GNUNET_OS_set_process_priority (getpid (), 35 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
36 GNUNET_SCHEDULER_PRIORITY_DEFAULT)) 36 GNUNET_SCHEDULER_PRIORITY_DEFAULT))
37 return 1; 37 return 1;
38 if (GNUNET_OK != 38 if (GNUNET_OK !=
39 GNUNET_OS_set_process_priority (getpid (), 39 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
40 GNUNET_SCHEDULER_PRIORITY_UI)) 40 GNUNET_SCHEDULER_PRIORITY_UI))
41 return 1; 41 return 1;
42 if (GNUNET_OK != 42 if (GNUNET_OK !=
43 GNUNET_OS_set_process_priority (getpid (), 43 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
44 GNUNET_SCHEDULER_PRIORITY_IDLE)) 44 GNUNET_SCHEDULER_PRIORITY_IDLE))
45 return 1; 45 return 1;
46 if (GNUNET_OK != 46 if (GNUNET_OK !=
47 GNUNET_OS_set_process_priority (getpid (), 47 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
48 GNUNET_SCHEDULER_PRIORITY_BACKGROUND)) 48 GNUNET_SCHEDULER_PRIORITY_BACKGROUND))
49 return 1; 49 return 1;
50 if (GNUNET_OK != 50 if (GNUNET_OK !=
51 GNUNET_OS_set_process_priority (getpid (), 51 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
52 GNUNET_SCHEDULER_PRIORITY_HIGH)) 52 GNUNET_SCHEDULER_PRIORITY_HIGH))
53 return 1; 53 return 1;
54 if (GNUNET_OK != 54 if (GNUNET_OK !=
55 GNUNET_OS_set_process_priority (getpid (), 55 GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
56 GNUNET_SCHEDULER_PRIORITY_HIGH)) 56 GNUNET_SCHEDULER_PRIORITY_HIGH))
57 return 1; 57 return 1;
58#ifndef MINGW 58#ifndef MINGW
diff --git a/src/util/test_os_start_process.c b/src/util/test_os_start_process.c
index 0b8860c7d..bd2eb2b09 100644
--- a/src/util/test_os_start_process.c
+++ b/src/util/test_os_start_process.c
@@ -38,7 +38,7 @@
38static char *test_phrase = "HELLO WORLD"; 38static char *test_phrase = "HELLO WORLD";
39static int ok; 39static int ok;
40 40
41static pid_t pid; 41static GNUNET_OS_Process *proc;
42/* Pipe to write to started processes stdin (on write end) */ 42/* Pipe to write to started processes stdin (on write end) */
43static struct GNUNET_DISK_PipeHandle *hello_pipe_stdin; 43static struct GNUNET_DISK_PipeHandle *hello_pipe_stdin;
44/* Pipe to read from started processes stdout (on read end) */ 44/* Pipe to read from started processes stdout (on read end) */
@@ -50,11 +50,13 @@ static void
50end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 50end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
51{ 51{
52 52
53 if (0 != PLIBC_KILL (pid, SIGTERM)) 53 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
54 { 54 {
55 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); 55 GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
56 } 56 }
57 GNUNET_OS_process_wait (pid); 57 GNUNET_OS_process_wait (proc);
58 GNUNET_OS_process_close (proc);
59 proc = NULL;
58 GNUNET_DISK_pipe_close(hello_pipe_stdout); 60 GNUNET_DISK_pipe_close(hello_pipe_stdout);
59 GNUNET_DISK_pipe_close(hello_pipe_stdin); 61 GNUNET_DISK_pipe_close(hello_pipe_stdin);
60} 62}
@@ -119,7 +121,7 @@ task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
119 return; 121 return;
120 } 122 }
121 123
122 pid = GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn, 124 proc = GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn,
123 "test_gnunet_echo_hello", "-", NULL); 125 "test_gnunet_echo_hello", "-", NULL);
124 GNUNET_free (fn); 126 GNUNET_free (fn);
125 127
diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c
index 2c3f95367..7321ed587 100644
--- a/src/util/test_resolver_api.c
+++ b/src/util/test_resolver_api.c
@@ -360,7 +360,7 @@ check()
360 int ok = 1 + 2 + 4 + 8; 360 int ok = 1 + 2 + 4 + 8;
361 char *fn; 361 char *fn;
362 char *pfx; 362 char *pfx;
363 pid_t pid; 363 GNUNET_OS_Process *proc;
364 char * const argv[] = 364 char * const argv[] =
365 { "test-resolver-api", "-c", "test_resolver_api_data.conf", 365 { "test-resolver-api", "-c", "test_resolver_api_data.conf",
366#if VERBOSE 366#if VERBOSE
@@ -372,7 +372,7 @@ check()
372 pfx = GNUNET_OS_installation_get_path(GNUNET_OS_IPK_BINDIR); 372 pfx = GNUNET_OS_installation_get_path(GNUNET_OS_IPK_BINDIR);
373 GNUNET_asprintf(&fn, "%s%cgnunet-service-resolver", pfx, DIR_SEPARATOR); 373 GNUNET_asprintf(&fn, "%s%cgnunet-service-resolver", pfx, DIR_SEPARATOR);
374 GNUNET_free(pfx); 374 GNUNET_free(pfx);
375 pid = GNUNET_OS_start_process(NULL, NULL, fn, "gnunet-service-resolver", 375 proc = GNUNET_OS_start_process(NULL, NULL, fn, "gnunet-service-resolver",
376#if VERBOSE 376#if VERBOSE
377 "-L", "DEBUG", 377 "-L", "DEBUG",
378#endif 378#endif
@@ -380,12 +380,14 @@ check()
380 GNUNET_free(fn); 380 GNUNET_free(fn);
381 GNUNET_assert(GNUNET_OK == GNUNET_PROGRAM_run((sizeof(argv) / sizeof(char *)) 381 GNUNET_assert(GNUNET_OK == GNUNET_PROGRAM_run((sizeof(argv) / sizeof(char *))
382 - 1, argv, "test-resolver-api", "nohelp", options, &run, &ok)); 382 - 1, argv, "test-resolver-api", "nohelp", options, &run, &ok));
383 if (0 != PLIBC_KILL(pid, SIGTERM)) 383 if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
384 { 384 {
385 GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "kill"); 385 GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "kill");
386 ok = 1; 386 ok = 1;
387 } 387 }
388 GNUNET_OS_process_wait(pid); 388 GNUNET_OS_process_wait (proc);
389 GNUNET_OS_process_close (proc);
390 proc = NULL;
389 if (ok != 0) 391 if (ok != 0)
390 fprintf(stderr, "Missed some resolutions: %u\n", ok); 392 fprintf(stderr, "Missed some resolutions: %u\n", ok);
391 return ok; 393 return ok;
diff --git a/src/vpn/gnunet-daemon-vpn.c b/src/vpn/gnunet-daemon-vpn.c
index f231ed782..a6f78d707 100644
--- a/src/vpn/gnunet-daemon-vpn.c
+++ b/src/vpn/gnunet-daemon-vpn.c
@@ -94,7 +94,7 @@ static unsigned char restart_hijack;
94/** 94/**
95 * The process id of the helper 95 * The process id of the helper
96 */ 96 */
97static pid_t helper_pid; 97static GNUNET_OS_Process *helper_proc;
98 98
99/** 99/**
100 * a list of outgoing dns-query-packets 100 * a list of outgoing dns-query-packets
@@ -177,8 +177,10 @@ cleanup(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
177 GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)); 177 GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
178 178
179 /* stop the helper */ 179 /* stop the helper */
180 PLIBC_KILL(helper_pid, SIGTERM); 180 GNUNET_OS_process_kill (helper_proc, SIGTERM);
181 GNUNET_OS_process_wait(helper_pid); 181 GNUNET_OS_process_wait (helper_proc);
182 GNUNET_OS_process_close (helper_proc);
183 helper_proc = NULL;
182 184
183 /* close the connection to the service-dns */ 185 /* close the connection to the service-dns */
184 if (dns_connection != NULL) 186 if (dns_connection != NULL)
@@ -202,7 +204,7 @@ start_helper_and_schedule(void *cls,
202 204
203 if (helper_in == NULL || helper_out == NULL) return; 205 if (helper_in == NULL || helper_out == NULL) return;
204 206
205 helper_pid = GNUNET_OS_start_process(helper_in, helper_out, "gnunet-helper-vpn", "gnunet-helper-vpn", NULL); 207 helper_proc = GNUNET_OS_start_process(helper_in, helper_out, "gnunet-helper-vpn", "gnunet-helper-vpn", NULL);
206 208
207 fh_from_helper = GNUNET_DISK_pipe_handle (helper_out, GNUNET_DISK_PIPE_END_READ); 209 fh_from_helper = GNUNET_DISK_pipe_handle (helper_out, GNUNET_DISK_PIPE_END_READ);
208 fh_to_helper = GNUNET_DISK_pipe_handle (helper_in, GNUNET_DISK_PIPE_END_WRITE); 210 fh_to_helper = GNUNET_DISK_pipe_handle (helper_in, GNUNET_DISK_PIPE_END_WRITE);
@@ -219,8 +221,10 @@ start_helper_and_schedule(void *cls,
219static void 221static void
220restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) { 222restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
221 // Kill the helper 223 // Kill the helper
222 PLIBC_KILL(helper_pid, SIGKILL); 224 GNUNET_OS_process_kill (helper_proc, SIGKILL);
223 GNUNET_OS_process_wait(helper_pid); 225 GNUNET_OS_process_wait (helper_proc);
226 GNUNET_OS_process_close (helper_proc);
227 helper_proc = NULL;
224 228
225 /* Tell the dns-service to rehijack the dns-port 229 /* Tell the dns-service to rehijack the dns-port
226 * The routing-table gets flushed if an interface disappears. 230 * The routing-table gets flushed if an interface disappears.
diff --git a/src/vpn/gnunet-service-dns.c b/src/vpn/gnunet-service-dns.c
index 6c95c7789..8dda2fffa 100644
--- a/src/vpn/gnunet-service-dns.c
+++ b/src/vpn/gnunet-service-dns.c
@@ -112,12 +112,12 @@ hijack(unsigned short port) {
112 112
113 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Hijacking, port is %d\n", port); 113 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Hijacking, port is %d\n", port);
114 snprintf(port_s, 6, "%d", port); 114 snprintf(port_s, 6, "%d", port);
115 GNUNET_OS_start_process(NULL, 115 GNUNET_OS_process_close (GNUNET_OS_start_process(NULL,
116 NULL, 116 NULL,
117 "gnunet-helper-hijack-dns", 117 "gnunet-helper-hijack-dns",
118 "gnunet-hijack-dns", 118 "gnunet-hijack-dns",
119 port_s, 119 port_s,
120 NULL); 120 NULL));
121} 121}
122 122
123/** 123/**