const struct GNUNET_SCHEDULER_TaskContext *tc)
{
struct RequestContext *pos = cls;
- pid_t pid;
+ GNUNET_OS_Process *proc;
char *binary;
char *config;
char *loprefix;
)
{
/* we're clearly running a test, don't daemonize */
- pid = do_start_process (NULL,
+ proc = do_start_process (NULL,
loprefix,
binary,
"-c", config,
}
else
{
- pid = do_start_process (NULL,
+ proc = do_start_process (NULL,
loprefix,
binary,
"-c", config,
GNUNET_free (config);
GNUNET_free (loprefix);
GNUNET_free (lopostfix);
- if (pid == -1)
+ if (proc == NULL)
{
if (pos->callback != NULL)
pos->callback (pos->cls, GNUNET_SYSERR);
* @param ... more arguments, NULL terminated
* @return PID of the started process, -1 on error
*/
-static pid_t
+static GNUNET_OS_Process *
do_start_process (const int *lsocks,
const char *first_arg, ...)
{
char *pos;
char *cp;
const char *last;
- pid_t pid;
+ GNUNET_OS_Process *proc;
argv_size = 1;
va_start (ap, first_arg);
while (NULL != (arg = (va_arg (ap, const char*))));
va_end (ap);
argv[argv_size] = NULL;
- pid = GNUNET_OS_start_process_v (lsocks, argv[0], argv);
+ proc = GNUNET_OS_start_process_v (lsocks, argv[0], argv);
while (argv_size > 0)
GNUNET_free (argv[--argv_size]);
GNUNET_free (argv);
- return pid;
+ return proc;
}
struct GNUNET_SERVER_Client *killing_client;
/**
- * Process ID of the child.
+ * Process structure pointer of the child.
*/
- pid_t pid;
+ GNUNET_OS_Process *proc;
/**
* Last time the config of this service was
/* FIXME: this test for config change is a bit too coarse grained */
if ( (0 == STAT (pos->config, &sbuf)) &&
(pos->mtime < sbuf.st_mtime) &&
- (pos->pid != 0) )
+ (pos->proc != NULL) )
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Restarting service `%s' due to configuration file change.\n"));
- if (0 != PLIBC_KILL (pos->pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
else
pos->backoff = GNUNET_TIME_UNIT_MILLISECONDS;
sl->name, sl->binary, sl->config);
#endif
if (GNUNET_YES == use_debug)
- sl->pid = do_start_process (lsocks,
+ sl->proc = do_start_process (lsocks,
loprefix,
sl->binary,
"-c", sl->config,
options,
NULL);
else
- sl->pid = do_start_process (lsocks,
+ sl->proc = do_start_process (lsocks,
loprefix,
sl->binary,
"-c", sl->config,
options,
NULL);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- _("Starting service `%s' (PID: %d)\n"),
- sl->name,
- (int) sl->pid);
+ if (sl->proc == NULL)
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ _("Failed to start service `%s'\n"),
+ sl->name);
+ else
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ _("Starting service `%s' (PID: %d)\n"),
+ sl->name,
+ (int) GNUNET_OS_process_get_pid (sl->proc));
GNUNET_free (loprefix);
GNUNET_free (options);
- /* FIXME: should check sl->pid */
+ /* FIXME: should check sl->proc */
}
running = pos;
return;
}
- if (pos->pid == 0)
+ if (pos->proc == NULL)
{
/* process is in delayed restart, simply remove it! */
free_entry (pos);
"Sending kill signal to service `%s', waiting for process to die.\n",
servicename);
#endif
- if (0 != PLIBC_KILL (pos->pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
pos->next = running;
running = pos;
/**
* Remove all entries for tasks that are not running
- * (pid = 0) from the running list (they will no longer
+ * (proc = NULL) from the running list (they will no longer
* be restarted since we are shutting down).
*/
static void
while (NULL != pos)
{
next = pos->next;
- if (pos->pid == 0)
+ if (pos->proc == NULL)
{
if (prev == NULL)
running = next;
pos = running;
while (NULL != pos)
{
- if (pos->pid != 0)
+ if (pos->proc != NULL)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Stopping service `%s' (PID: %d)\n",
pos->name,
- pos->pid);
- if (0 != PLIBC_KILL (pos->pid, SIGTERM))
+ GNUNET_OS_process_get_pid (pos->proc));
+ if (0 != GNUNET_OS_process_kill (pos->proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
}
pos = pos->next;
pos = running;
while (pos != NULL)
{
- if ( (pos->pid == 0) &&
+ if ( (pos->proc == NULL) &&
(GNUNET_YES != in_shutdown) )
{
if (GNUNET_TIME_absolute_get_remaining (pos->restartAt).rel_value == 0)
while (NULL != (pos = next))
{
next = pos->next;
- if (pos->pid == 0)
+ if (pos->proc == NULL)
{
prev = pos;
continue;
}
- if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->pid,
+ if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->proc,
&statusType,
&statusCode))) ||
( (ret == GNUNET_NO) ||
statstr = _( /* process termination method */ "unknown");
statcode = 0;
}
- pos->pid = 0;
+ GNUNET_OS_process_close (pos->proc);
+ pos->proc = NULL;
if (NULL != pos->killing_client)
{
if (prev == NULL)
struct GNUNET_MessageHeader *hello;
int connect_status;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_pid));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
struct GNUNET_MessageHeader *hello;
int connect_status;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
struct GNUNET_CORE_Handle *ch;
struct GNUNET_PeerIdentity id;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"ARM process %u stopped\n", p->arm_pid);
#endif
static int
check ()
{
- pid_t pid;
+ GNUNET_OS_Process *proc;
char cfg_name[128];
char *const argv[] = {
"perf-datastore-api",
sizeof (cfg_name),
"test_datastore_api_data_%s.conf",
plugin_name);
- pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
argv, "perf-datastore-api", "nohelp",
options, &run, NULL);
- if (0 != PLIBC_KILL (pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
ok = 1;
}
- GNUNET_OS_process_wait(pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
return ok;
}
{
char cfg_name[128];
#if START_DATASTORE
- pid_t pid;
+ GNUNET_OS_Process *proc;
#endif
char *const argv[] = {
"test-datastore-api",
"test_datastore_api_data_%s.conf",
plugin_name);
#if START_DATASTORE
- pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
argv, "test-datastore-api", "nohelp",
options, &run, NULL);
#if START_DATASTORE
- if (0 != PLIBC_KILL (pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
ok = 1;
}
- GNUNET_OS_process_wait(pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
#endif
if (ok != 0)
fprintf (stderr, "Missed some testcases: %u\n", ok);
static int
check ()
{
- pid_t pid;
+ GNUNET_OS_Process *proc;
char cfg_name[128];
char *const argv[] = {
"test-datastore-api-management",
sizeof (cfg_name),
"test_datastore_api_data_%s.conf",
plugin_name);
- pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
argv, "test-datastore-api", "nohelp",
options, &run, NULL);
- if (0 != PLIBC_KILL (pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
ok = 1;
}
- GNUNET_OS_process_wait(pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
if (ok != 0)
fprintf (stderr, "Missed some testcases: %u\n", ok);
return ok;
struct GNUNET_DHT_FindPeerHandle *find_peer_handle;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (p->arm_pid);
+ GNUNET_OS_process_wait (p->arm_proc);
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
main (int argc, char *argv[])
{
#if START_DAEMON
- pid_t daemon;
+ GNUNET_OS_Process *daemon;
#endif
int ok;
struct GNUNET_ECRS_URI *uri;
}
#if START_DAEMON
daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
- GNUNET_GE_ASSERT (NULL, daemon > 0);
+ GNUNET_GE_ASSERT (NULL, daemon != NULL);
CHECK (GNUNET_OK ==
GNUNET_wait_for_daemon_running (NULL, cfg,
60 * GNUNET_CRON_SECONDS));
#if START_DAEMON
GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
+ GNUNET_OS_process_close (daemon);
#endif
GNUNET_GC_free (cfg);
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
#include "gnunet_util.h"
#include "gnunet_fsui_lib.h"
-#define DEBUG_VERBOSE GNUNET_NO
+#define DEBUG_VERBOSE GNUNET_YES
#define CHECK(a) if (!(a)) { ok = GNUNET_NO; GNUNET_GE_BREAK(ectx, 0); goto FAILURE; }
main (int argc, char *argv[])
{
#if START_DAEMON
- pid_t daemon;
+ GNUNET_OS_Process *daemon;
#endif
int ok;
char *fn = NULL;
GNUNET_disk_directory_remove (NULL,
"/tmp/gnunet-fsui-recursive_download_test/");
daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
- GNUNET_GE_ASSERT (NULL, daemon > 0);
+ GNUNET_GE_ASSERT (NULL, daemon != NULL);
CHECK (GNUNET_OK ==
GNUNET_wait_for_daemon_running (NULL, cfg,
30 * GNUNET_CRON_SECONDS));
#if START_DAEMON
GNUNET_GE_BREAK (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
+ GNUNET_OS_process_close (daemon);
+ daemon = NULL;
#endif
GNUNET_GC_free (cfg);
return (ok == GNUNET_YES) ? 0 : 1;
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
if (uri_this != NULL)
GNUNET_FS_uri_destroy (uri_this);
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_PeerIdentity id;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
struct GNUNET_CONFIGURATION_Handle *cfg;
struct GNUNET_PeerIdentity id;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
main (int argc, char *argv[])
{
#if START_DAEMON
- pid_t daemon;
+ GNUNET_OS_Process *daemon;
#endif
int ok;
char *fn = NULL;
#if START_DAEMON
GNUNET_disk_directory_remove (NULL, "/tmp/gnunet-fsui-searchranktest/");
daemon = GNUNET_daemon_start (NULL, cfg, "peer.conf", GNUNET_NO);
- GNUNET_GE_ASSERT (NULL, daemon > 0);
+ GNUNET_GE_ASSERT (NULL, daemon != NULL);
CHECK (GNUNET_OK ==
GNUNET_wait_for_daemon_running (NULL, cfg,
30 * GNUNET_CRON_SECONDS));
#if START_DAEMON
GNUNET_GE_ASSERT (NULL, GNUNET_OK == GNUNET_daemon_stop (NULL, daemon));
+ GNUNET_OS_process_close (daemon);
+ daemon = NULL;
#endif
GNUNET_GC_free (cfg);
return (ok == GNUNET_YES) ? 0 : 1;
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
struct GNUNET_CONFIGURATION_Handle *cfg;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_MessageHeader *hello;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
#if START_ARM
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Killing ARM process.\n");
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(p->arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(p->arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "ARM process %u stopped\n", p->arm_pid);
+ "ARM process %u stopped\n", GNUNET_OS_process_get_pid (p->arm_proc));
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
struct GNUNET_CORE_Handle *core;
struct GNUNET_STATISTICS_Handle *stats;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
#if START_ARM
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Killing hostlist server ARM process.\n");
- if (0 != PLIBC_KILL (adv_peer.arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (adv_peer.arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(adv_peer.arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(adv_peer.arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Hostlist server ARM process %u stopped\n", adv_peer.arm_pid);
+ "Hostlist server ARM process %u stopped\n", GNUNET_OS_process_get_pid (adv_peer.arm_proc));
+ GNUNET_OS_process_close (adv_peer->arm_proc);
+ adv_peer->arm_proc = NULL;
#endif
#if START_ARM
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Killing hostlist client ARM process.\n");
- if (0 != PLIBC_KILL (learn_peer.arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (learn_peer.arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- if (GNUNET_OS_process_wait(learn_peer.arm_pid) != GNUNET_OK)
+ if (GNUNET_OS_process_wait(learn_peer.arm_proc) != GNUNET_OK)
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
- "Hostlist client ARM process %u stopped\n", learn_peer.arm_pid);
+ "Hostlist client ARM process %u stopped\n", GNUNET_OS_process_get_pid (learn_peer.arm_proc));
+ GNUNET_OS_process_close (learn_peer->arm_proc);
+ learn_peer->arm_proc = NULL;
#endif
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down scheduler\n");
unsigned int result;
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE
"-L", "DEBUG",
#include "gnunet_configuration_lib.h"
#include "gnunet_scheduler_lib.h"
+/**
+ * Process information (OS-dependent)
+ */
+typedef struct _GNUNET_OS_Process GNUNET_OS_Process;
+
/**
* Possible installation paths to request
#define GNUNET_OS_get_hostname_max_length() 255
#endif
+/**
+ * Allocates new process structure
+ *
+ * Should be made internal?
+ *
+ * @return pointer to allocated structure
+ */
+GNUNET_OS_Process *GNUNET_OS_process_alloc ();
+
+
+/**
+ * Get process structure for current process
+ *
+ * The pointer it returns points to static memory location and must not be
+ * deallocated/closed
+ *
+ * @return pointer to the process sturcutre for this process
+ */
+GNUNET_OS_Process *GNUNET_OS_process_current ();
+
+
+/**
+ * Sends @sig to the process
+ *
+ * @param proc pointer to process structure
+ * @param sig signal
+ * @return 0 on success, -1 on error
+ */
+int GNUNET_OS_process_kill (GNUNET_OS_Process *proc, int sig);
+
+/**
+ * Get process ID
+ *
+ * Should be made internal?
+ *
+ * @param proc pointer to process structure
+ * @return process ID
+ */
+pid_t GNUNET_OS_process_get_pid (GNUNET_OS_Process *proc);
+
+/**
+ * Set process ID
+ *
+ * Should be made internal?
+ *
+ * @param proc pointer to process structure
+ * @param pid process ID
+ */
+void GNUNET_OS_process_set_pid (GNUNET_OS_Process *proc, pid_t pid);
+
+#if WINDOWS
+/**
+ * Get process handle
+ *
+ * Should be made internal?
+ *
+ * @param proc pointer to process structure
+ * @return process handle
+ */
+HANDLE GNUNET_OS_process_get_handle (GNUNET_OS_Process *proc);
+
+/**
+ * Set process handle
+ *
+ * Should be made internal?
+ *
+ * @param proc pointer to process structure
+ * @param handle process handle
+ */
+void GNUNET_OS_process_set_handle(GNUNET_OS_Process *proc, HANDLE handle);
+#endif
+
+/**
+ * Cleans up process structure contents (OS-dependent) and deallocates it
+ *
+ * @param proc pointer to process structure
+ */
+void GNUNET_OS_process_close (GNUNET_OS_Process *proc);
/**
* Set process priority
*
- * @param proc id of the process
+ * @param proc pointer to process structure
* @param prio priority value
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
-int GNUNET_OS_set_process_priority (pid_t proc,
+int GNUNET_OS_set_process_priority (GNUNET_OS_Process *proc,
enum GNUNET_SCHEDULER_Priority prio);
* @param pipe_stdout pipe to use to get output from child process (or NULL)
* @param filename name of the binary
* @param ... NULL-terminated list of arguments to the process
- * @return process ID of the new process, -1 on error
+ * @return pointer to process structure of the new process, NULL on error
*/
-pid_t
+GNUNET_OS_Process *
GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
struct GNUNET_DISK_PipeHandle *pipe_stdout,
const char *filename, ...);
* @param filename name of the binary
* @param argv NULL-terminated list of arguments to the process,
* including the process name as the first argument
- * @return process ID of the new process, -1 on error
+ * @return pointer to process structure of the new process, NULL on error
*/
-pid_t GNUNET_OS_start_process_v (const int *lsocks,
- const char *filename, char *const argv[]);
+GNUNET_OS_Process *
+GNUNET_OS_start_process_v (const int *lsocks, const char *filename,
+ char *const argv[]);
/**
* Retrieve the status of a process
- * @param proc process ID
+ * @param proc pointer to process structure
* @param type status type
* @param code return code/signal number
* @return GNUNET_OK on success, GNUNET_NO if the process is still running, GNUNET_SYSERR otherwise
*/
-int GNUNET_OS_process_status (pid_t proc, enum GNUNET_OS_ProcessStatusType *type,
- unsigned long *code);
+int GNUNET_OS_process_status (GNUNET_OS_Process *proc,
+ enum GNUNET_OS_ProcessStatusType *type, unsigned long *code);
/**
* Wait for a process
- * @param proc process ID to wait for
+ * @param proc pointer to process structure of the process to wait for
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise
*/
-int GNUNET_OS_process_wait (pid_t proc);
+int GNUNET_OS_process_wait (GNUNET_OS_Process *proc);
#if 0 /* keep Emacsens' auto-indent happy */
/**
* PID of the process that we started last.
*/
- pid_t pid;
+ GNUNET_OS_Process *proc;
/**
* In which phase are we during the start of
static int
check ()
{
- GNUNET_OS_start_process (NULL, NULL, "gnunet-monkey",
- "gnunet-monkey",
- "./bug_null_pointer_exception", NULL);
+ GNUNET_OS_process_close (GNUNET_OS_start_process (NULL, NULL,
+ "gnunet-monkey",
+ "gnunet-monkey",
+ "./bug_null_pointer_exception",
+ NULL));
+
return 0;
}
NULL
};
#if START_SERVICE
- pid_t pid;
+ GNUNET_OS_Process *proc;
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
- pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo",
+ proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo",
"gnunet-service-peerinfo",
#if DEBUG_PEERINFO
"-L", "DEBUG",
numpeers,
NUM_REQUESTS * NUM_REQUESTS / 2);
#if START_SERVICE
- if (0 != PLIBC_KILL (pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
ok = 1;
}
- GNUNET_OS_process_wait(pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
+
#endif
return ok;
}
check ()
{
int ok = 3;
- pid_t pid;
+ GNUNET_OS_Process *proc;
char *const argv[] = { "test-peerinfo-api",
"-c",
"test_peerinfo_api_data.conf",
struct GNUNET_GETOPT_CommandLineOption options[] = {
GNUNET_GETOPT_OPTION_END
};
- pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo",
+ proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-peerinfo",
"gnunet-service-peerinfo",
#if DEBUG_PEERINFO
"-L", "DEBUG",
GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1,
argv, "test-peerinfo-api", "nohelp",
options, &run, &ok);
- if (0 != PLIBC_KILL (pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
ok = 1;
}
- GNUNET_OS_process_wait(pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
return ok;
}
#include "gnunet_scheduler_lib.h"
#include "gnunet_statistics_service.h"
-#define DEBUG_STATISTICS GNUNET_NO
+#define DEBUG_STATISTICS GNUNET_YES
#define START_SERVICE GNUNET_YES
GNUNET_GETOPT_OPTION_END
};
#if START_SERVICE
- pid_t pid;
- pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+ GNUNET_OS_Process *proc;
+ proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
"gnunet-service-statistics",
#if DEBUG_STATISTICS
"-L", "DEBUG",
GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp",
options, &run, &ok);
#if START_SERVICE
- if (0 != PLIBC_KILL (pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
ok = 1;
}
- GNUNET_OS_process_wait(pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
#endif
if (ok != 0)
return ok;
ok = 1;
#if START_SERVICE
/* restart to check persistence! */
- pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+ proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
"gnunet-service-statistics",
#if DEBUG_STATISTICS
"-L", "DEBUG",
GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp",
options, &run_more, &ok);
#if START_SERVICE
- if (0 != PLIBC_KILL (pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
ok = 1;
}
- GNUNET_OS_process_wait(pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
#endif
return ok;
}
GNUNET_GETOPT_OPTION_END
};
#if START_SERVICE
- pid_t pid;
- pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
+ GNUNET_OS_Process *proc;
+ proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-statistics",
"gnunet-service-statistics",
#if DEBUG_STATISTICS
"-L", "DEBUG",
GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp",
options, &run, &ok);
#if START_SERVICE
- if (0 != PLIBC_KILL (pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
ok = 1;
}
- GNUNET_OS_process_wait(pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
#endif
return ok;
}
{
char *peer_number;
char *connect_number;
- pid_t mem_process;
+ GNUNET_OS_Process *mem_process;
GNUNET_asprintf(&peer_number, "%llu", num_peers);
GNUNET_asprintf(&connect_number, "%llu", expected_connections);
mem_process = GNUNET_OS_start_process (NULL, NULL, "./memsize.pl",
"memsize.pl", "totals.txt", peer_number, connect_number, NULL);
- GNUNET_OS_process_wait(mem_process);
+ GNUNET_OS_process_wait (mem_process);
+ GNUNET_OS_process_close (mem_process);
+ mem_process = NULL;
}
#endif
{
case SP_COPYING:
/* confirm copying complete */
- if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code))
+ if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code))
{
if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0)
{
"gnunet-peerinfo", "gnunet-peerinfo", "-c", d->cfgfile,
"-sq");
#endif
- d->pid = GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo",
+ d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "gnunet-peerinfo",
"gnunet-peerinfo",
"-c", d->cfgfile,
"-sq", NULL);
#endif
if (d->ssh_port_str == NULL)
{
- d->pid = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh",
+ d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh",
"ssh",
#if !DEBUG_TESTING
"-q",
}
else
{
- d->pid = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh",
+ d->proc = GNUNET_OS_start_process (NULL, d->pipe_stdout, "ssh",
"ssh", "-p", d->ssh_port_str,
#if !DEBUG_TESTING
"-q",
GNUNET_DISK_pipe_close_end(d->pipe_stdout, GNUNET_DISK_PIPE_END_WRITE);
GNUNET_free (dst);
}
- if (-1 == d->pid)
+ if (NULL == d->proc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Could not start `%s' process to create hostkey.\n"),
d->cb = NULL;
GNUNET_DISK_pipe_close(d->pipe_stdout);
d->pipe_stdout = NULL;
- (void) PLIBC_KILL (d->pid, SIGKILL);
- GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->pid));
- d->pid = 0;
+ (void) GNUNET_OS_process_kill (d->proc, SIGKILL);
+ GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc));
+ GNUNET_OS_process_close (d->proc);
+ d->proc = NULL;
if (NULL != cb)
cb (d->cb_cls,
NULL,
}
GNUNET_DISK_pipe_close(d->pipe_stdout);
d->pipe_stdout = NULL;
- (void) PLIBC_KILL (d->pid, SIGKILL);
- GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->pid));
- d->pid = 0;
+ (void) GNUNET_OS_process_kill (d->proc, SIGKILL);
+ GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (d->proc));
+ GNUNET_OS_process_close (d->proc);
+ d->proc = NULL;
#if DEBUG_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Successfully got hostkey!\n");
"-L", "DEBUG",
"-s");
#endif
- d->pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
+ d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
"gnunet-arm",
"-c", d->cfgfile,
#if DEBUG_TESTING
#endif
if (d->ssh_port_str == NULL)
{
- d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh",
+ d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh",
"ssh",
#if !DEBUG_TESTING
"-q",
else
{
- d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh",
+ d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh",
"ssh", "-p", d->ssh_port_str,
#if !DEBUG_TESTING
"-q",
}
GNUNET_free (dst);
}
- if (-1 == d->pid)
+ if (NULL == d->proc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_("Could not start `%s' process to start GNUnet.\n"),
&start_fsm, d);
break;
case SP_START_ARMING:
- if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code))
+ if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code))
{
if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0)
{
break;
case SP_SHUTDOWN_START:
/* confirm copying complete */
- if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code))
+ if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code))
{
if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0)
{
break;
case SP_CONFIG_UPDATE:
/* confirm copying complete */
- if (GNUNET_OK != GNUNET_OS_process_status (d->pid, &type, &code))
+ if (GNUNET_OK != GNUNET_OS_process_status (d->proc, &type, &code))
{
if (GNUNET_TIME_absolute_get_remaining(d->max_timeout).rel_value == 0) /* FIXME: config update should take timeout parameter! */
{
if (ret->ssh_port_str == NULL)
{
- ret->pid = GNUNET_OS_start_process (NULL, NULL, "scp",
+ ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp",
"scp",
#if !DEBUG_TESTING
"-q",
}
else
{
- ret->pid = GNUNET_OS_start_process (NULL, NULL, "scp",
+ ret->proc = GNUNET_OS_start_process (NULL, NULL, "scp",
"scp", "-P", ret->ssh_port_str,
#if !DEBUG_TESTING
"-q",
ret->cfgfile, arg, NULL);
}
GNUNET_free (arg);
- if (-1 == ret->pid)
+ if (NULL == ret->proc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_
else
arg = GNUNET_strdup (d->hostname);
- d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+ d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
#if !DEBUG_TESTING
"-q",
#endif
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
#endif
- d->pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
+ d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
"gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
else
arg = GNUNET_strdup (d->hostname);
- d->pid = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
+ d->proc = GNUNET_OS_start_process (NULL, NULL, "ssh", "ssh",
#if !DEBUG_TESTING
"-q",
#endif
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Stopping gnunet-arm with config `%s' locally.\n", d->cfgfile);
#endif
- d->pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
+ d->proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-arm",
"gnunet-arm",
#if DEBUG_TESTING
"-L", "DEBUG",
GNUNET_asprintf (&arg, "%s@%s:%s", d->username, d->hostname, d->cfgfile);
else
GNUNET_asprintf (&arg, "%s:%s", d->hostname, d->cfgfile);
- d->pid = GNUNET_OS_start_process (NULL, NULL, "scp", "scp",
+ d->proc = GNUNET_OS_start_process (NULL, NULL, "scp", "scp",
#if !DEBUG_TESTING
"-q",
#endif
d->cfgfile, arg, NULL);
GNUNET_free (arg);
- if (-1 == d->pid)
+ if (NULL == d->proc)
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_
FILE *temp_friend_handle;
unsigned int pg_iter;
char *temp_service_path;
- pid_t *pidarr;
+ GNUNET_OS_Process **procarr;
char *arg;
char * mytemp;
enum GNUNET_OS_ProcessStatusType type;
int ret;
int max_wait = 10;
- pidarr = GNUNET_malloc(sizeof(pid_t) * pg->total);
+ procarr = GNUNET_malloc(sizeof(GNUNET_OS_Process *) * pg->total);
for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
{
mytemp = GNUNET_DISK_mktemp("friends");
if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
{
GNUNET_asprintf (&arg, "%s/friends", temp_service_path);
- pidarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv",
+ procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv",
"mv", mytemp, arg, NULL);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_asprintf (&arg, "%s@%s:%s/friends", pg->peers[pg_iter].daemon->username, pg->peers[pg_iter].daemon->hostname, temp_service_path);
else
GNUNET_asprintf (&arg, "%s:%s/friends", pg->peers[pg_iter].daemon->hostname, temp_service_path);
- pidarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp",
+ procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp",
"scp", mytemp, arg, NULL);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Checking copy status of file %d\n"), pg_iter);
#endif
- if (pidarr[pg_iter] != 0) /* Check for already completed! */
+ if (procarr[pg_iter] != NULL) /* Check for already completed! */
{
- if (GNUNET_OS_process_status(pidarr[pg_iter], &type, &return_code) != GNUNET_OK)
+ if (GNUNET_OS_process_status(procarr[pg_iter], &type, &return_code) != GNUNET_OK)
{
ret = GNUNET_SYSERR;
}
}
else
{
- pidarr[pg_iter] = 0;
+ GNUNET_OS_process_close (procarr[pg_iter]);
+ procarr[pg_iter] = NULL;
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("File %d copied\n"), pg_iter);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Finished copying all friend files!\n"));
#endif
- GNUNET_free(pidarr);
+ GNUNET_free(procarr);
return ret;
}
static struct BlacklistContext blacklist_ctx;
unsigned int pg_iter;
char *temp_service_path;
- pid_t *pidarr;
+ GNUNET_OS_Process **procarr;
char *arg;
char *mytemp;
enum GNUNET_OS_ProcessStatusType type;
char *pos;
char *temp_transports;
- pidarr = GNUNET_malloc(sizeof(pid_t) * pg->total);
+ procarr = GNUNET_malloc(sizeof(GNUNET_OS_Process *) * pg->total);
for (pg_iter = 0; pg_iter < pg->total; pg_iter++)
{
mytemp = GNUNET_DISK_mktemp("blacklist");
if (pg->peers[pg_iter].daemon->hostname == NULL) /* Local, just copy the file */
{
GNUNET_asprintf (&arg, "%s/blacklist", temp_service_path);
- pidarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv",
+ procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "mv",
"mv", mytemp, arg, NULL);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
GNUNET_asprintf (&arg, "%s@%s:%s/blacklist", pg->peers[pg_iter].daemon->username, pg->peers[pg_iter].daemon->hostname, temp_service_path);
else
GNUNET_asprintf (&arg, "%s:%s/blacklist", pg->peers[pg_iter].daemon->hostname, temp_service_path);
- pidarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp",
+ procarr[pg_iter] = GNUNET_OS_start_process (NULL, NULL, "scp",
"scp", mytemp, arg, NULL);
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Checking copy status of file %d\n"), pg_iter);
#endif
- if (pidarr[pg_iter] != 0) /* Check for already completed! */
+ if (procarr[pg_iter] != NULL) /* Check for already completed! */
{
- if (GNUNET_OS_process_status(pidarr[pg_iter], &type, &return_code) != GNUNET_OK)
+ if (GNUNET_OS_process_status(procarr[pg_iter], &type, &return_code) != GNUNET_OK)
{
ret = GNUNET_SYSERR;
}
}
else
{
- pidarr[pg_iter] = 0;
+ GNUNET_OS_process_close (procarr[pg_iter]);
+ procarr[pg_iter] = NULL;
#if VERBOSE_TESTING
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("File %d copied\n"), pg_iter);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
_("Finished copying all blacklist files!\n"));
#endif
- GNUNET_free(pidarr);
+ GNUNET_free(procarr);
return ret;
}
/**
* The process id of the server process (if behind NAT)
*/
- pid_t server_pid;
+ GNUNET_OS_Process *server_proc;
/**
* List of open TCP sessions.
char inet4[INET_ADDRSTRLEN];
char *address_as_string;
char *port_as_string;
- pid_t pid;
+ GNUNET_OS_Process *proc;
const struct sockaddr *sa = (const struct sockaddr *)addr;
#if DEBUG_TCP_NAT
#endif
/* Start the client process */
- pid = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL);
+ proc = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL);
GNUNET_free(address_as_string);
GNUNET_free(port_as_string);
- GNUNET_OS_process_wait (pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
}
"Starting gnunet-nat-server process cmd: %s %s\n", "gnunet-nat-server", plugin->internal_address);
#endif
/* Start the server process */
- plugin->server_pid = GNUNET_OS_start_process(NULL, plugin->server_stdout, "gnunet-nat-server", "gnunet-nat-server", plugin->internal_address, NULL);
- if (plugin->server_pid == GNUNET_SYSERR)
+ plugin->server_proc = GNUNET_OS_start_process(NULL, plugin->server_stdout, "gnunet-nat-server", "gnunet-nat-server", plugin->internal_address, NULL);
+ if (plugin->server_proc == NULL)
{
#if DEBUG_TCP_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
if (plugin->behind_nat == GNUNET_YES)
{
- if (0 != PLIBC_KILL (plugin->server_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (plugin->server_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (plugin->server_pid);
+ GNUNET_OS_process_wait (plugin->server_proc);
+ GNUNET_OS_process_close (plugin->server_proc);
+ plugin->server_proc = NULL;
}
GNUNET_free_non_null(plugin->bind_address);
GNUNET_free (plugin);
/**
* The process id of the server process (if behind NAT)
*/
- pid_t server_pid;
+ GNUNET_OS_Process *server_proc;
};
}
if (plugin->behind_nat == GNUNET_YES)
{
- if (0 != PLIBC_KILL (plugin->server_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (plugin->server_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (plugin->server_pid);
+ GNUNET_OS_process_wait (plugin->server_proc);
+ GNUNET_OS_process_close (plugin->server_proc);
+ plugin->server_proc = NULL;
}
return GNUNET_OK;
}
char addr_buf[INET_ADDRSTRLEN];
char *address_as_string;
char *port_as_string;
- pid_t pid;
+ GNUNET_OS_Process *proc;
const struct IPv4UdpAddress *t4;
GNUNET_assert(addrlen == sizeof(struct IPv4UdpAddress));
#endif
/* Start the server process */
- pid = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL);
+ proc = GNUNET_OS_start_process(NULL, NULL, "gnunet-nat-client", "gnunet-nat-client", plugin->external_address, address_as_string, port_as_string, NULL);
GNUNET_free(address_as_string);
GNUNET_free(port_as_string);
- GNUNET_OS_process_wait (pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
}
/**
plugin->internal_address);
#endif
/* Start the server process */
- plugin->server_pid = GNUNET_OS_start_process(NULL,
+ plugin->server_proc = GNUNET_OS_start_process(NULL,
plugin->server_stdout,
"gnunet-nat-server",
"gnunet-nat-server",
plugin->internal_address, NULL);
- if (plugin->server_pid == GNUNET_SYSERR)
+ if (plugin->server_proc == NULL)
{
#if DEBUG_UDP
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
/**
* The process id of the server process (if behind NAT)
*/
- pid_t server_pid;
+ GNUNET_OS_Process *server_proc;
/**
* The interface of the wlan card given to us by the user.
"Starting gnunet-wlan-helper process cmd: %s %s\n", "gnunet-wlan-helper", plugin->interface);
#endif
/* Start the server process */
- plugin->server_pid = GNUNET_OS_start_process(plugin->server_stdin, plugin->server_stdout, "gnunet-transport-wlan-helper", "gnunet-transport-wlan-helper", plugin->interface, NULL);
- if (plugin->server_pid == GNUNET_SYSERR)
+ plugin->server_proc = GNUNET_OS_start_process(plugin->server_stdin, plugin->server_stdout, "gnunet-transport-wlan-helper", "gnunet-transport-wlan-helper", plugin->interface, NULL);
+ if (plugin->server_proc == NULL)
{
#if DEBUG_TCP_NAT
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_PeerIdentity id;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (p->arm_pid);
+ GNUNET_OS_process_wait (p->arm_proc);
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL,
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
"gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_PeerIdentity id;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (p->arm_pid);
+ GNUNET_OS_process_wait (p->arm_proc);
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL, "gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
"-L", "DEBUG",
struct GNUNET_TRANSPORT_Handle *th;
struct GNUNET_PeerIdentity id;
#if START_ARM
- pid_t arm_pid;
+ GNUNET_OS_Process *arm_proc;
#endif
};
stop_arm (struct PeerContext *p)
{
#if START_ARM
- if (0 != PLIBC_KILL (p->arm_pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (p->arm_proc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
- GNUNET_OS_process_wait (p->arm_pid);
+ GNUNET_OS_process_wait (p->arm_proc);
+ GNUNET_OS_process_close (p->arm_proc);
+ p->arm_proc = NULL;
#endif
GNUNET_CONFIGURATION_destroy (p->cfg);
}
{
p->cfg = GNUNET_CONFIGURATION_create ();
#if START_ARM
- p->arm_pid = GNUNET_OS_start_process (NULL, NULL,
+ p->arm_proc = GNUNET_OS_start_process (NULL, NULL,
"gnunet-service-arm",
"gnunet-service-arm",
#if VERBOSE_ARM
* Process ID of the "find" process that we use for
* entropy gathering.
*/
-static pid_t genproc;
+static GNUNET_OS_Process *genproc;
/**
* Function called by libgcrypt whenever we are
return;
if (current == total)
{
- if (genproc != 0)
+ if (genproc != NULL)
{
- if (0 != PLIBC_KILL (genproc, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (genproc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill");
GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc));
- genproc = 0;
+ GNUNET_OS_process_close (genproc);
+ genproc = NULL;
}
return;
}
- if (genproc != 0)
+ if (genproc != NULL)
{
ret = GNUNET_OS_process_status (genproc, &type, &code);
if (ret == GNUNET_NO)
GNUNET_break (0);
return;
}
- if (0 != PLIBC_KILL (genproc, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (genproc, SIGTERM))
GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "kill");
GNUNET_break (GNUNET_OK == GNUNET_OS_process_wait (genproc));
- genproc = 0;
+ GNUNET_OS_process_close (genproc);
+ genproc = NULL;
}
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("Starting `%s' process to generate entropy\n"), "find");
static void
killfind ()
{
- if (genproc != 0)
+ if (genproc != NULL)
{
- PLIBC_KILL (genproc, SIGKILL);
- genproc = 0;
+ GNUNET_OS_process_kill (genproc, SIGKILL);
+ GNUNET_OS_process_close (genproc);
+ genproc = NULL;
}
}
/* end of crypto_random.c */
+
#include "gnunet_os_lib.h"
#include "disk.h"
+struct _GNUNET_OS_Process
+{
+ pid_t pid;
+#if WINDOWS
+ HANDLE handle;
+#endif
+};
+
+static GNUNET_OS_Process current_process;
+
+GNUNET_OS_Process *
+GNUNET_OS_process_alloc ()
+{
+ GNUNET_OS_Process *ret = GNUNET_malloc (sizeof (GNUNET_OS_Process));
+ ret->pid = 0;
+#if WINDOWS
+ ret->handle = NULL;
+#endif
+ return ret;
+}
+
+/**
+ * Get process structure for current process
+ *
+ * The pointer it returns points to static memory location and must not be
+ * deallocated/closed
+ *
+ * @return pointer to the process sturcutre for this process
+ */
+GNUNET_OS_Process *
+GNUNET_OS_process_current ()
+{
+#if WINDOWS
+ current_process.pid = GetCurrentProcessId ();
+ current_process.handle = GetCurrentProcess ();
+#else
+ current_process.pid = 0;
+#endif
+ return ¤t_process;
+}
+
+int
+GNUNET_OS_process_kill (GNUNET_OS_Process *proc, int sig)
+{
+#if WINDOWS
+ if (sig == SIGKILL || sig == SIGTERM)
+ {
+ HANDLE h = GNUNET_OS_process_get_handle (proc);
+ if (NULL == h)
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n", GNUNET_OS_process_get_pid (proc), h);
+ return -1;
+ }
+ if (!TerminateProcess (h, 0))
+ {
+ SetErrnoFromWinError (GetLastError ());
+ return -1;
+ }
+ else
+ return 0;
+ }
+ errno = EINVAL;
+ return -1;
+#else
+ return kill (GNUNET_OS_process_get_pid (proc), sig);
+#endif
+}
+
+pid_t
+GNUNET_OS_process_get_pid (GNUNET_OS_Process *proc)
+{
+ return proc->pid;
+}
+
+void
+GNUNET_OS_process_set_pid (GNUNET_OS_Process *proc, pid_t pid)
+{
+ proc->pid = pid;
+}
+
+#if WINDOWS
+HANDLE
+GNUNET_OS_process_get_handle (GNUNET_OS_Process *proc)
+{
+ return proc->handle;
+}
+
+void
+GNUNET_OS_process_set_handle(GNUNET_OS_Process *proc, HANDLE handle)
+{
+ if (proc->handle != NULL)
+ CloseHandle (proc->handle);
+ proc->handle = handle;
+}
+#endif
+
+void
+GNUNET_OS_process_close (GNUNET_OS_Process *proc)
+{
+#if WINDOWS
+ if (proc->handle != NULL)
+ CloseHandle (proc->handle);
+#endif
+ GNUNET_free (proc);
+}
+
#if WINDOWS
#include "gnunet_signal_lib.h"
/**
* @brief Waits for a process to terminate and invokes the SIGCHLD handler
- * @param h handle to the process
+ * @param proc pointer to process structure
*/
static DWORD WINAPI
-ChildWaitThread (HANDLE h)
+ChildWaitThread (void *arg)
{
- WaitForSingleObject (h, INFINITE);
+ GNUNET_OS_Process *proc = (GNUNET_OS_Process *) arg;
+ WaitForSingleObject (proc->handle, INFINITE);
if (w32_sigchld_handler)
w32_sigchld_handler ();
- CloseHandle (h);
return 0;
}
#endif
/**
* Set process priority
*
- * @param proc id of the process
+ * @param proc pointer to process structure
* @param prio priority value
* @return GNUNET_OK on success, GNUNET_SYSERR on error
*/
int
-GNUNET_OS_set_process_priority (pid_t proc,
+GNUNET_OS_set_process_priority (GNUNET_OS_Process *proc,
enum GNUNET_SCHEDULER_Priority prio)
{
int rprio;
+ pid_t pid;
GNUNET_assert (prio < GNUNET_SCHEDULER_PRIORITY_COUNT);
if (prio == GNUNET_SCHEDULER_PRIORITY_KEEP)
return GNUNET_OK;
+
/* convert to MINGW/Unix values */
switch (prio)
{
GNUNET_assert (0);
return GNUNET_SYSERR;
}
+
+ pid = GNUNET_OS_process_get_pid (proc);
+
/* Set process priority */
#ifdef MINGW
- SetPriorityClass (GetCurrentProcess (), rprio);
+ {
+ HANDLE h = GNUNET_OS_process_get_handle (proc);
+ GNUNET_assert (h != NULL);
+ SetPriorityClass (h, rprio);
+ }
#elif LINUX
- if ( (0 == proc) ||
- (proc == getpid () ) )
+ if ( (0 == pid) ||
+ (pid == getpid () ) )
{
int have = nice (0);
int delta = rprio - have;
}
else
{
- if (0 != setpriority (PRIO_PROCESS, proc, rprio))
+ if (0 != setpriority (PRIO_PROCESS, pid, rprio))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING |
* @param pipe_stdout pipe to use to get output from child process (or NULL)
* @param filename name of the binary
* @param ... NULL-terminated list of arguments to the process
- * @return process ID of the new process, -1 on error
+ * @return pointer to process structure of the new process, NULL on error
*/
-pid_t
+GNUNET_OS_Process *
GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin,
struct GNUNET_DISK_PipeHandle *pipe_stdout,
const char *filename, ...)
{
- /* FIXME: Make this work on windows!!! */
va_list ap;
#ifndef MINGW
pid_t ret;
+ GNUNET_OS_Process *gnunet_proc = NULL;
char **argv;
int argc;
int fd_stdout_write;
GNUNET_DISK_pipe_close_end(pipe_stdin, GNUNET_DISK_PIPE_END_READ);
sleep (1);
#endif
+ gnunet_proc = GNUNET_OS_process_alloc ();
+ GNUNET_OS_process_set_pid (gnunet_proc, ret);
}
GNUNET_free (argv);
- return ret;
+ return gnunet_proc;
}
if (pipe_stdout != NULL)
int findresult;
STARTUPINFO start;
PROCESS_INFORMATION proc;
+ GNUNET_OS_Process *gnunet_proc = NULL;
HANDLE stdin_handle;
HANDLE stdout_handle;
{
SetErrnoFromWinError (GetLastError ());
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "FindExecutable", filename);
- return (pid_t) -1;
+ return NULL;
}
if (!CreateProcessA
{
SetErrnoFromWinError (GetLastError ());
GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "CreateProcess", path);
- return (pid_t) -1;
+ return NULL;
}
- CreateThread (NULL, 64000, ChildWaitThread, proc.hProcess, 0, NULL);
+ gnunet_proc = GNUNET_OS_process_alloc ();
+ GNUNET_OS_process_set_pid (gnunet_proc, proc.dwProcessId);
+ GNUNET_OS_process_set_handle (gnunet_proc, proc.hProcess);
+
+ CreateThread (NULL, 64000, ChildWaitThread, (void *) gnunet_proc, 0, NULL);
CloseHandle (proc.hThread);
GNUNET_free (cmd);
- return proc.dwProcessId;
+ return gnunet_proc;
#endif
}
* @param argv NULL-terminated list of arguments to the process
* @return process ID of the new process, -1 on error
*/
-pid_t
+GNUNET_OS_Process *
GNUNET_OS_start_process_v (const int *lsocks,
const char *filename, char *const argv[])
{
pid_t ret;
char lpid[16];
char fds[16];
+ GNUNET_OS_Process *gnunet_proc = NULL;
int i;
int j;
int k;
be plenty in practice */
sleep (1);
#endif
+ gnunet_proc = GNUNET_OS_process_alloc ();
+ GNUNET_OS_process_set_pid (gnunet_proc, ret);
}
GNUNET_array_grow (lscp, ls, 0);
- return ret;
+ return gnunet_proc;
}
if (lscp != NULL)
{
int argcount = 0;
char *non_const_filename = NULL;
int filenamelen = 0;
+ GNUNET_OS_Process *gnunet_proc = NULL;
GNUNET_assert (lsocks == NULL);
/* Count the number of arguments */
&proc))
{
SetErrnoFromWinError (GetLastError ());
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "fork");
- return -1;
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "CreateProcess");
+ return NULL;
}
- CreateThread (NULL, 64000, ChildWaitThread, proc.hProcess, 0, NULL);
+ gnunet_proc = GNUNET_OS_process_alloc ();
+ GNUNET_OS_process_set_pid (gnunet_proc, proc.dwProcessId);
+ GNUNET_OS_process_set_handle (gnunet_proc, proc.hProcess);
+
+ CreateThread (NULL, 64000, ChildWaitThread, (void *) gnunet_proc, 0, NULL);
CloseHandle (proc.hThread);
GNUNET_free (cmd);
GNUNET_free (non_const_argv[--argcount]);
GNUNET_free (non_const_argv);
- return proc.dwProcessId;
+ return gnunet_proc;
#endif
}
* @return GNUNET_OK on success, GNUNET_NO if the process is still running, GNUNET_SYSERR otherwise
*/
int
-GNUNET_OS_process_status (pid_t proc, enum GNUNET_OS_ProcessStatusType *type,
+GNUNET_OS_process_status (GNUNET_OS_Process *proc, enum GNUNET_OS_ProcessStatusType *type,
unsigned long *code)
{
#ifndef MINGW
int ret;
GNUNET_assert (0 != proc);
- ret = waitpid (proc, &status, WNOHANG);
+ ret = waitpid (GNUNET_OS_process_get_pid (proc), &status, WNOHANG);
if (ret < 0)
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
*code = 0;
return GNUNET_NO;
}
- if (proc != ret)
+ if (GNUNET_OS_process_get_pid (proc) != ret)
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "waitpid");
return GNUNET_SYSERR;
}
#else
HANDLE h;
- DWORD c;
+ DWORD c, error_code, ret;
- h = OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, proc);
- if (INVALID_HANDLE_VALUE == h)
+ h = GNUNET_OS_process_get_handle (proc);
+ ret = GNUNET_OS_process_get_pid (proc);
+ if (h == NULL || ret == 0)
{
- SetErrnoFromWinError (GetLastError ());
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "OpenProcess");
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n", ret, h);
return GNUNET_SYSERR;
}
+ if (h == NULL)
+ h = GetCurrentProcess ();
- c = GetExitCodeProcess (h, &c);
+ SetLastError (0);
+ ret = GetExitCodeProcess (h, &c);
+ error_code = GetLastError ();
+ if (ret == 0 || error_code != NO_ERROR)
+ {
+ SetErrnoFromWinError (error_code);
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "GetExitCodeProcess");
+ return GNUNET_SYSERR;
+ }
if (STILL_ACTIVE == c)
{
*type = GNUNET_OS_PROCESS_RUNNING;
*code = 0;
- CloseHandle (h);
return GNUNET_NO;
}
*type = GNUNET_OS_PROCESS_EXITED;
*code = c;
- CloseHandle (h);
#endif
return GNUNET_OK;
/**
* Wait for a process
- * @param proc process ID to wait for
+ * @param proc pointer to process structure
* @return GNUNET_OK on success, GNUNET_SYSERR otherwise
*/
int
-GNUNET_OS_process_wait (pid_t proc)
+GNUNET_OS_process_wait (GNUNET_OS_Process *proc)
{
+ pid_t pid = GNUNET_OS_process_get_pid (proc);
#ifndef MINGW
- if (proc != waitpid (proc, NULL, 0))
+ if (pid != waitpid (pid, NULL, 0))
return GNUNET_SYSERR;
return GNUNET_OK;
HANDLE h;
int ret;
- h = OpenProcess (PROCESS_QUERY_INFORMATION, FALSE, proc);
- if (INVALID_HANDLE_VALUE == h)
+ h = GNUNET_OS_process_get_handle (proc);
+ if (NULL == h)
{
- SetErrnoFromWinError (GetLastError ());
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING, "Invalid process information {%d, %08X}\n", pid, h);
return GNUNET_SYSERR;
}
+ if (h == NULL)
+ h = GetCurrentProcess ();
if (WAIT_OBJECT_0 != WaitForSingleObject (h, INFINITE))
{
else
ret = GNUNET_OK;
- CloseHandle (h);
-
return ret;
#endif
}
if (sched->current_priority != pos->priority)
{
sched->current_priority = pos->priority;
- (void) GNUNET_OS_set_process_priority (0, pos->priority);
+ (void) GNUNET_OS_set_process_priority (GNUNET_OS_process_current (), pos->priority);
}
sched->active_task = pos;
#if PROFILE_DELAYS
{
pid_t child;
if (GNUNET_OK !=
- GNUNET_OS_set_process_priority (getpid (),
+ GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
GNUNET_SCHEDULER_PRIORITY_DEFAULT))
return 1;
if (GNUNET_OK !=
- GNUNET_OS_set_process_priority (getpid (),
+ GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
GNUNET_SCHEDULER_PRIORITY_UI))
return 1;
if (GNUNET_OK !=
- GNUNET_OS_set_process_priority (getpid (),
+ GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
GNUNET_SCHEDULER_PRIORITY_IDLE))
return 1;
if (GNUNET_OK !=
- GNUNET_OS_set_process_priority (getpid (),
+ GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
GNUNET_SCHEDULER_PRIORITY_BACKGROUND))
return 1;
if (GNUNET_OK !=
- GNUNET_OS_set_process_priority (getpid (),
+ GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
GNUNET_SCHEDULER_PRIORITY_HIGH))
return 1;
if (GNUNET_OK !=
- GNUNET_OS_set_process_priority (getpid (),
+ GNUNET_OS_set_process_priority (GNUNET_OS_process_current (),
GNUNET_SCHEDULER_PRIORITY_HIGH))
return 1;
#ifndef MINGW
static char *test_phrase = "HELLO WORLD";
static int ok;
-static pid_t pid;
+static GNUNET_OS_Process *proc;
/* Pipe to write to started processes stdin (on write end) */
static struct GNUNET_DISK_PipeHandle *hello_pipe_stdin;
/* Pipe to read from started processes stdout (on read end) */
end_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
- if (0 != PLIBC_KILL (pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
}
- GNUNET_OS_process_wait (pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
GNUNET_DISK_pipe_close(hello_pipe_stdout);
GNUNET_DISK_pipe_close(hello_pipe_stdin);
}
return;
}
- pid = GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn,
+ proc = GNUNET_OS_start_process (hello_pipe_stdin, hello_pipe_stdout, fn,
"test_gnunet_echo_hello", "-", NULL);
GNUNET_free (fn);
int ok = 1 + 2 + 4 + 8;
char *fn;
char *pfx;
- pid_t pid;
+ GNUNET_OS_Process *proc;
char * const argv[] =
{ "test-resolver-api", "-c", "test_resolver_api_data.conf",
#if VERBOSE
pfx = GNUNET_OS_installation_get_path(GNUNET_OS_IPK_BINDIR);
GNUNET_asprintf(&fn, "%s%cgnunet-service-resolver", pfx, DIR_SEPARATOR);
GNUNET_free(pfx);
- pid = GNUNET_OS_start_process(NULL, NULL, fn, "gnunet-service-resolver",
+ proc = GNUNET_OS_start_process(NULL, NULL, fn, "gnunet-service-resolver",
#if VERBOSE
"-L", "DEBUG",
#endif
GNUNET_free(fn);
GNUNET_assert(GNUNET_OK == GNUNET_PROGRAM_run((sizeof(argv) / sizeof(char *))
- 1, argv, "test-resolver-api", "nohelp", options, &run, &ok));
- if (0 != PLIBC_KILL(pid, SIGTERM))
+ if (0 != GNUNET_OS_process_kill (proc, SIGTERM))
{
GNUNET_log_strerror(GNUNET_ERROR_TYPE_WARNING, "kill");
ok = 1;
}
- GNUNET_OS_process_wait(pid);
+ GNUNET_OS_process_wait (proc);
+ GNUNET_OS_process_close (proc);
+ proc = NULL;
if (ok != 0)
fprintf(stderr, "Missed some resolutions: %u\n", ok);
return ok;
/**
* The process id of the helper
*/
-static pid_t helper_pid;
+static GNUNET_OS_Process *helper_proc;
/**
* a list of outgoing dns-query-packets
GNUNET_assert (0 != (tskctx->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN));
/* stop the helper */
- PLIBC_KILL(helper_pid, SIGTERM);
- GNUNET_OS_process_wait(helper_pid);
+ GNUNET_OS_process_kill (helper_proc, SIGTERM);
+ GNUNET_OS_process_wait (helper_proc);
+ GNUNET_OS_process_close (helper_proc);
+ helper_proc = NULL;
/* close the connection to the service-dns */
if (dns_connection != NULL)
if (helper_in == NULL || helper_out == NULL) return;
- helper_pid = GNUNET_OS_start_process(helper_in, helper_out, "gnunet-helper-vpn", "gnunet-helper-vpn", NULL);
+ helper_proc = GNUNET_OS_start_process(helper_in, helper_out, "gnunet-helper-vpn", "gnunet-helper-vpn", NULL);
fh_from_helper = GNUNET_DISK_pipe_handle (helper_out, GNUNET_DISK_PIPE_END_READ);
fh_to_helper = GNUNET_DISK_pipe_handle (helper_in, GNUNET_DISK_PIPE_END_WRITE);
static void
restart_helper(void* cls, const struct GNUNET_SCHEDULER_TaskContext* tskctx) {
// Kill the helper
- PLIBC_KILL(helper_pid, SIGKILL);
- GNUNET_OS_process_wait(helper_pid);
+ GNUNET_OS_process_kill (helper_proc, SIGKILL);
+ GNUNET_OS_process_wait (helper_proc);
+ GNUNET_OS_process_close (helper_proc);
+ helper_proc = NULL;
/* Tell the dns-service to rehijack the dns-port
* The routing-table gets flushed if an interface disappears.
GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, "Hijacking, port is %d\n", port);
snprintf(port_s, 6, "%d", port);
- GNUNET_OS_start_process(NULL,
+ GNUNET_OS_process_close (GNUNET_OS_start_process(NULL,
NULL,
"gnunet-helper-hijack-dns",
"gnunet-hijack-dns",
port_s,
- NULL);
+ NULL));
}
/**