commit 7ef333ddb373d88cfc10c84507d22fb9f5224ad5
parent f5362eca930d06a228bc6d23eafacb01d6c28ae8
Author: Christian Grothoff <christian@grothoff.org>
Date: Sun, 15 Mar 2026 00:10:20 +0100
migrate more logic from GNUNET_OS_process to new GNUNET_process API
Diffstat:
7 files changed, 338 insertions(+), 258 deletions(-)
diff --git a/src/cli/fs/gnunet-auto-share.c b/src/cli/fs/gnunet-auto-share.c
@@ -154,7 +154,7 @@ static struct GNUNET_DISK_PipeHandle *sigpipe;
/**
* Handle to the 'gnunet-publish' process that we executed.
*/
-static struct GNUNET_OS_Process *publish_proc;
+static struct GNUNET_Process *publish_proc;
/**
@@ -318,7 +318,9 @@ do_stop_task (void *cls)
do_shutdown = GNUNET_YES;
if (NULL != publish_proc)
{
- GNUNET_OS_process_kill (publish_proc, SIGKILL);
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_process_kill (publish_proc,
+ SIGKILL));
return;
}
if (NULL != run_task)
@@ -370,7 +372,10 @@ maint_child_death (void *cls)
/* consume the signal */
GNUNET_break (0 < GNUNET_DISK_file_read (pr, &c, sizeof(c)));
- retval = GNUNET_OS_process_status (publish_proc, &type, &code);
+ retval = GNUNET_process_wait (publish_proc,
+ false,
+ &type,
+ &code);
GNUNET_assert (GNUNET_SYSERR != retval);
if (GNUNET_NO == retval)
{
@@ -386,7 +391,7 @@ maint_child_death (void *cls)
}
GNUNET_assert (GNUNET_OK == retval);
- GNUNET_OS_process_destroy (publish_proc);
+ GNUNET_process_destroy (publish_proc);
publish_proc = NULL;
if (GNUNET_YES == do_shutdown)
@@ -480,23 +485,35 @@ work (void *cls)
argv[argc] = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_INFO, _ ("Publishing `%s'\n"), wi->filename);
GNUNET_assert (NULL == publish_proc);
- publish_proc = GNUNET_OS_start_process_vap (GNUNET_OS_USE_PIPE_CONTROL,
- NULL,
- NULL,
- NULL,
- "gnunet-publish",
- (char * const*) argv);
- if (NULL == publish_proc)
+ publish_proc = GNUNET_process_create ();
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_set_options (
+ publish_proc,
+ GNUNET_process_option_std_inheritance (
+ GNUNET_OS_USE_PIPE_CONTROL)));
+ if ( (GNUNET_OK !=
+ GNUNET_process_set_command_argv (publish_proc,
+ "gnunet-publish",
+ (const char **) argv)) ||
+ (GNUNET_OK !=
+ GNUNET_process_start (publish_proc)) )
{
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
_ ("Failed to run `%s'\n"),
"gnunet-publish");
- GNUNET_CONTAINER_DLL_insert (work_head, work_tail, wi);
+ GNUNET_CONTAINER_DLL_insert (work_head,
+ work_tail,
+ wi);
+ GNUNET_process_destroy (publish_proc);
+ publish_proc = NULL;
run_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &work, NULL);
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES,
+ &work,
+ NULL);
return;
}
- pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ);
+ pr = GNUNET_DISK_pipe_handle (sigpipe,
+ GNUNET_DISK_PIPE_END_READ);
run_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
pr,
&maint_child_death,
diff --git a/src/lib/testing/testing_api_cmd_signal.c b/src/lib/testing/testing_api_cmd_signal.c
@@ -54,7 +54,7 @@ signal_run (void *cls,
{
struct SignalState *ss = cls;
const struct GNUNET_TESTING_Command *pcmd;
- struct GNUNET_OS_Process **process;
+ struct GNUNET_Process **process;
pcmd
= GNUNET_TESTING_interpreter_lookup_command (is,
@@ -70,9 +70,9 @@ signal_run (void *cls,
GNUNET_TESTING_get_trait_process (pcmd,
&process))
GNUNET_TESTING_FAIL (is);
- GNUNET_break (0 ==
- GNUNET_OS_process_kill (*process,
- ss->signal));
+ GNUNET_break (GNUNET_OK ==
+ GNUNET_process_kill (*process,
+ ss->signal));
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Signaling '%d'..\n",
ss->signal);
diff --git a/src/lib/util/test_common_logging_runtime_loglevels.c b/src/lib/util/test_common_logging_runtime_loglevels.c
@@ -47,7 +47,7 @@ static int ok;
static int phase = 0;
-static struct GNUNET_OS_Process *proc;
+static struct GNUNET_Process *proc;
/* Pipe to read from started processes stdout (on read end) */
static struct GNUNET_DISK_PipeHandle *pipe_stdout;
@@ -63,16 +63,24 @@ runone (void);
static void
end_task (void *cls)
{
- GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Ending phase %d, ok is %d\n", phase,
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Ending phase %d, ok is %d\n",
+ phase,
ok);
if (NULL != proc)
{
- if (0 != GNUNET_OS_process_kill (proc, GNUNET_TERM_SIG))
+ if (GNUNET_OK !=
+ GNUNET_process_kill (proc,
+ GNUNET_TERM_SIG))
{
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
+ "kill");
}
- GNUNET_OS_process_wait (proc);
- GNUNET_OS_process_destroy (proc);
+ GNUNET_process_wait (proc,
+ true,
+ NULL,
+ NULL);
+ GNUNET_process_destroy (proc);
proc = NULL;
}
if (NULL != read_task)
@@ -346,7 +354,7 @@ read_call (void *cls)
static void
-runone ()
+runone (void)
{
const struct GNUNET_DISK_FileHandle *stdout_read_handle;
@@ -405,30 +413,42 @@ runone ()
break;
}
- proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, pipe_stdout, NULL,
- "./test_common_logging_dummy",
- "test_common_logging_dummy", NULL);
- GNUNET_assert (NULL != proc);
+ proc = GNUNET_process_create ();
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_set_options (
+ proc,
+ GNUNET_process_option_inherit_wpipe (pipe_stdout,
+ STDOUT_FILENO)));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_set_command_va (proc,
+ "./test_common_logging_dummy",
+ "test_common_logging_dummy",
+ NULL));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_start (proc));
putenv ((char*) "GNUNET_FORCE_LOG=");
putenv ((char*) "GNUNET_LOG=");
/* Close the write end of the read pipe */
- GNUNET_DISK_pipe_close_end (pipe_stdout, GNUNET_DISK_PIPE_END_WRITE);
+ GNUNET_DISK_pipe_close_end (pipe_stdout,
+ GNUNET_DISK_PIPE_END_WRITE);
stdout_read_handle =
- GNUNET_DISK_pipe_handle (pipe_stdout, GNUNET_DISK_PIPE_END_READ);
+ GNUNET_DISK_pipe_handle (pipe_stdout,
+ GNUNET_DISK_PIPE_END_READ);
die_task =
- GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply
- (GNUNET_TIME_UNIT_SECONDS, 10),
+ GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (
+ GNUNET_TIME_UNIT_SECONDS,
+ 10),
&end_task,
NULL);
bytes = 0;
buf_ptr = buf;
- memset (&buf, 0, sizeof(buf));
-
+ memset (&buf,
+ 0,
+ sizeof(buf));
read_task = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
stdout_read_handle,
&read_call,
@@ -445,13 +465,15 @@ task (void *cls)
int
-main (int argc, char *argv[])
+main (int argc,
+ char *argv[])
{
GNUNET_log_setup ("test-common-logging-runtime-loglevels",
"WARNING",
NULL);
ok = 1;
- GNUNET_SCHEDULER_run (&task, &ok);
+ GNUNET_SCHEDULER_run (&task,
+ &ok);
return ok;
}
diff --git a/src/service/arm/arm_api.c b/src/service/arm/arm_api.c
@@ -655,25 +655,42 @@ start_arm_service (struct GNUNET_ARM_Handle *h,
enum GNUNET_OS_InheritStdioFlags std_inheritance,
struct GNUNET_DISK_FileHandle *sigfd)
{
- struct GNUNET_OS_Process *proc;
+ struct GNUNET_Process *proc;
char *cbinary;
char *binary;
char *quotedbinary;
char *config;
char *loprefix;
char *lopostfix;
- int ld[2];
- int *lsocks;
+ enum GNUNET_GenericReturnValue ret;
- if (NULL == sigfd)
+ if (GNUNET_OK !=
+ GNUNET_CONFIGURATION_get_value_string (h->cfg,
+ "arm",
+ "BINARY",
+ &cbinary))
{
- lsocks = NULL;
+ GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
+ "arm",
+ "BINARY");
+ GNUNET_free (loprefix);
+ GNUNET_free (lopostfix);
+ return GNUNET_ARM_RESULT_IS_NOT_KNOWN;
}
- else
+
+ proc = GNUNET_process_create ();
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_set_options (
+ proc,
+ GNUNET_process_option_std_inheritance (
+ std_inheritance)));
+ if (NULL != sigfd)
{
- ld[0] = sigfd->fd;
- ld[1] = -1;
- lsocks = ld;
+ GNUNET_assert (
+ GNUNET_OK ==
+ GNUNET_process_set_options (
+ proc,
+ GNUNET_process_option_inherit_lsock (sigfd->fd)));
}
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (h->cfg,
@@ -682,7 +699,8 @@ start_arm_service (struct GNUNET_ARM_Handle *h,
&loprefix))
loprefix = GNUNET_strdup ("");
else
- loprefix = GNUNET_CONFIGURATION_expand_dollar (h->cfg, loprefix);
+ loprefix = GNUNET_CONFIGURATION_expand_dollar (h->cfg,
+ loprefix);
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (h->cfg,
"arm",
@@ -693,30 +711,19 @@ start_arm_service (struct GNUNET_ARM_Handle *h,
lopostfix = GNUNET_CONFIGURATION_expand_dollar (h->cfg,
lopostfix);
if (GNUNET_OK !=
- GNUNET_CONFIGURATION_get_value_string (h->cfg,
- "arm",
- "BINARY",
- &cbinary))
- {
- GNUNET_log_config_missing (GNUNET_ERROR_TYPE_WARNING,
- "arm",
- "BINARY");
- GNUNET_free (loprefix);
- GNUNET_free (lopostfix);
- return GNUNET_ARM_RESULT_IS_NOT_KNOWN;
- }
- if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_filename (h->cfg,
"arm",
"CONFIG",
&config))
config = NULL;
- binary = GNUNET_OS_get_libexec_binary_path (GNUNET_OS_project_data_gnunet (),
- cbinary);
+ binary = GNUNET_OS_get_libexec_binary_path (
+ GNUNET_OS_project_data_gnunet (),
+ cbinary);
GNUNET_asprintf ("edbinary,
"\"%s\"",
binary);
GNUNET_free (cbinary);
+
if ( (GNUNET_YES ==
GNUNET_CONFIGURATION_have_value (h->cfg,
"TESTING",
@@ -733,54 +740,52 @@ start_arm_service (struct GNUNET_ARM_Handle *h,
/* Means we are ONLY running locally */
/* we're clearly running a test, don't daemonize */
if (NULL == config)
- proc = GNUNET_OS_start_process_s (std_inheritance,
- lsocks,
- loprefix,
- quotedbinary,
- /* no daemonization! */
- lopostfix,
- NULL);
+ ret = GNUNET_process_set_command_va (proc,
+ loprefix,
+ quotedbinary,
+ /* no daemonization! */
+ lopostfix,
+ NULL);
else
- proc = GNUNET_OS_start_process_s (std_inheritance,
- lsocks,
- loprefix,
- quotedbinary,
- "-c",
- config,
- /* no daemonization! */
- lopostfix,
- NULL);
+ ret = GNUNET_process_set_command_va (proc,
+ loprefix,
+ quotedbinary,
+ "-c",
+ config,
+ /* no daemonization! */
+ lopostfix,
+ NULL);
}
else
{
if (NULL == config)
- proc = GNUNET_OS_start_process_s (std_inheritance,
- lsocks,
- loprefix,
- quotedbinary,
- "-d", /* do daemonize */
- lopostfix,
- NULL);
+ ret = GNUNET_process_set_command_va (proc,
+ loprefix,
+ quotedbinary,
+ "-d", /* do daemonize */
+ lopostfix,
+ NULL);
else
- proc = GNUNET_OS_start_process_s (std_inheritance,
- lsocks,
- loprefix,
- quotedbinary,
- "-c",
- config,
- "-d", /* do daemonize */
- lopostfix,
- NULL);
+ ret = GNUNET_process_set_command_va (proc,
+ loprefix,
+ quotedbinary,
+ "-c",
+ config,
+ "-d", /* do daemonize */
+ lopostfix,
+ NULL);
}
GNUNET_free (binary);
GNUNET_free (quotedbinary);
- if (NULL != config)
- GNUNET_free (config);
+ GNUNET_free (config);
GNUNET_free (loprefix);
GNUNET_free (lopostfix);
- if (NULL == proc)
+ if (GNUNET_OK != ret)
+ return GNUNET_ARM_RESULT_START_FAILED;
+ ret = GNUNET_process_start (proc);
+ GNUNET_process_destroy (proc);
+ if (GNUNET_OK != ret)
return GNUNET_ARM_RESULT_START_FAILED;
- GNUNET_OS_process_destroy (proc);
return GNUNET_ARM_RESULT_STARTING;
}
diff --git a/src/service/arm/gnunet-service-arm.c b/src/service/arm/gnunet-service-arm.c
@@ -158,7 +158,7 @@ struct ServiceList
/**
* Process structure pointer of the child.
*/
- struct GNUNET_OS_Process *proc;
+ struct GNUNET_Process *proc;
/**
* Process exponential backoff time
@@ -750,21 +750,29 @@ start_process (struct ServiceList *sl,
char *options;
enum GNUNET_GenericReturnValue use_debug;
bool is_simple_service;
- int *lsocks;
- unsigned int ls;
char *binary;
char *quotedbinary;
+ enum GNUNET_GenericReturnValue ret;
- /* calculate listen socket list */
- lsocks = NULL;
- ls = 0;
+ GNUNET_assert (NULL == sl->proc);
+ sl->proc = GNUNET_process_create ();
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_set_options (
+ sl->proc,
+ GNUNET_process_option_std_inheritance (
+ sl->pipe_control
+ ? GNUNET_OS_INHERIT_STD_OUT_AND_ERR
+ | GNUNET_OS_USE_PIPE_CONTROL
+ : GNUNET_OS_INHERIT_STD_OUT_AND_ERR)));
for (struct ServiceListeningInfo *sli = sl->listen_head;
NULL != sli;
sli = sli->next)
{
- GNUNET_array_append (lsocks,
- ls,
- GNUNET_NETWORK_get_fd (sli->listen_socket));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_set_options (
+ sl->proc,
+ GNUNET_process_option_inherit_lsock (
+ GNUNET_NETWORK_get_fd (sli->listen_socket))));
if (NULL != sli->accept_task)
{
GNUNET_SCHEDULER_cancel (sli->accept_task);
@@ -772,10 +780,6 @@ start_process (struct ServiceList *sl,
}
}
- GNUNET_array_append (lsocks,
- ls,
- -1);
-
/* obtain configuration */
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -817,7 +821,10 @@ start_process (struct ServiceList *sl,
{
/* combine "fin_options" with "options" */
optpos = options;
- GNUNET_asprintf (&options, "%s %s", fin_options, optpos);
+ GNUNET_asprintf (&options,
+ "%s %s",
+ fin_options,
+ optpos);
GNUNET_free (fin_options);
GNUNET_free (optpos);
}
@@ -848,11 +855,10 @@ start_process (struct ServiceList *sl,
choices,
&service_type)) &&
(0 == strcasecmp (service_type,
- "SIMPLE")))
+ "SIMPLE")) )
is_simple_service = true;
}
- GNUNET_assert (NULL == sl->proc);
if (is_simple_service)
{
/* A simple service will receive no GNUnet specific
@@ -872,15 +878,11 @@ start_process (struct ServiceList *sl,
if (NULL != options)
options = GNUNET_CONFIGURATION_expand_dollar (cfg,
options);
- sl->proc = GNUNET_OS_start_process_s (sl->pipe_control
- ? GNUNET_OS_INHERIT_STD_OUT_AND_ERR
- | GNUNET_OS_USE_PIPE_CONTROL
- : GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- lsocks,
- loprefix,
- quotedbinary,
- options,
- NULL);
+ ret = GNUNET_process_set_command_va (sl->proc,
+ loprefix,
+ quotedbinary,
+ options,
+ NULL);
}
else
{
@@ -890,22 +892,17 @@ start_process (struct ServiceList *sl,
sl->name,
sl->binary,
sl->config);
- binary = GNUNET_OS_get_libexec_binary_path (GNUNET_OS_project_data_gnunet ()
- ,
- sl->binary);
+ binary = GNUNET_OS_get_libexec_binary_path (
+ GNUNET_OS_project_data_gnunet (),
+ sl->binary);
GNUNET_asprintf ("edbinary,
"\"%s\"",
binary);
-
if (GNUNET_YES == use_debug)
{
if (NULL == sl->config)
- sl->proc = GNUNET_OS_start_process_s (
- sl->pipe_control
- ? GNUNET_OS_INHERIT_STD_OUT_AND_ERR
- | GNUNET_OS_USE_PIPE_CONTROL
- : GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- lsocks,
+ ret = GNUNET_process_set_command_va (
+ sl->proc,
loprefix,
quotedbinary,
"-L",
@@ -913,12 +910,8 @@ start_process (struct ServiceList *sl,
options,
NULL);
else
- sl->proc = GNUNET_OS_start_process_s (
- sl->pipe_control
- ? GNUNET_OS_INHERIT_STD_OUT_AND_ERR
- | GNUNET_OS_USE_PIPE_CONTROL
- : GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- lsocks,
+ ret = GNUNET_process_set_command_va (
+ sl->proc,
loprefix,
quotedbinary,
"-c",
@@ -931,23 +924,15 @@ start_process (struct ServiceList *sl,
else
{
if (NULL == sl->config)
- sl->proc = GNUNET_OS_start_process_s (
- sl->pipe_control
- ? GNUNET_OS_INHERIT_STD_OUT_AND_ERR
- | GNUNET_OS_USE_PIPE_CONTROL
- : GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- lsocks,
+ ret = GNUNET_process_set_command_va (
+ sl->proc,
loprefix,
quotedbinary,
options,
NULL);
else
- sl->proc = GNUNET_OS_start_process_s (
- sl->pipe_control
- ? GNUNET_OS_INHERIT_STD_OUT_AND_ERR
- | GNUNET_OS_USE_PIPE_CONTROL
- : GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- lsocks,
+ ret = GNUNET_process_set_command_va (
+ sl->proc,
loprefix,
quotedbinary,
"-c",
@@ -956,40 +941,45 @@ start_process (struct ServiceList *sl,
NULL);
}
}
- GNUNET_free (binary);
- GNUNET_free (quotedbinary);
- sl->last_started_at = GNUNET_TIME_absolute_get ();
- if (NULL == sl->proc)
+
+ if (GNUNET_OK != ret)
{
- GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
- "Failed to start service `%s'\n",
- sl->name);
- if (client)
- signal_result (client,
- sl->name,
- request_id,
- GNUNET_ARM_RESULT_START_FAILED);
+ GNUNET_break (0);
+ goto failure;
}
- else
+
+ sl->last_started_at = GNUNET_TIME_absolute_get ();
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Starting service `%s'\n",
+ sl->name);
+ broadcast_status (sl->name,
+ GNUNET_ARM_SERVICE_STARTING,
+ NULL);
+ if (client)
+ signal_result (client,
+ sl->name,
+ request_id,
+ GNUNET_ARM_RESULT_STARTING);
+ goto cleanup;
+failure:
+ if (NULL != sl->proc)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO,
- "Starting service `%s'\n",
- sl->name);
- broadcast_status (sl->name,
- GNUNET_ARM_SERVICE_STARTING,
- NULL);
- if (client)
- signal_result (client,
- sl->name,
- request_id,
- GNUNET_ARM_RESULT_STARTING);
+ GNUNET_process_destroy (sl->proc);
+ sl->proc = NULL;
}
- /* clean up */
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Failed to start service `%s'\n",
+ sl->name);
+ if (client)
+ signal_result (client,
+ sl->name,
+ request_id,
+ GNUNET_ARM_RESULT_START_FAILED);
+cleanup:
+ GNUNET_free (binary);
+ GNUNET_free (quotedbinary);
GNUNET_free (loprefix);
GNUNET_free (options);
- GNUNET_array_grow (lsocks,
- ls,
- 0);
}
@@ -1350,8 +1340,11 @@ handle_stop (void *cls, const struct GNUNET_ARM_Message *amsg)
broadcast_status (servicename, GNUNET_ARM_SERVICE_STOPPING, NULL);
/* no signal_start - only when it's STOPPED */
sl->killed_at = GNUNET_TIME_absolute_get ();
- if (0 != GNUNET_OS_process_kill (sl->proc, GNUNET_TERM_SIG))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+ if (GNUNET_OK !=
+ GNUNET_process_kill (sl->proc,
+ GNUNET_TERM_SIG))
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
+ "kill");
sl->killing_client = client;
sl->killing_client_request_id = request_id;
}
@@ -1576,10 +1569,15 @@ shutdown_task (void *cls)
nxt = pos->next;
if (NULL != pos->proc)
{
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Stopping service `%s'\n", pos->name);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+ "Stopping service `%s'\n",
+ pos->name);
pos->killed_at = GNUNET_TIME_absolute_get ();
- if (0 != GNUNET_OS_process_kill (pos->proc, GNUNET_TERM_SIG))
- GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill");
+ if (GNUNET_OK !=
+ GNUNET_process_kill (pos->proc,
+ GNUNET_TERM_SIG))
+ GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
+ "kill");
}
else
{
@@ -1718,8 +1716,11 @@ maint_child_death (void *cls)
int status;
pid_t pid;
- pid = GNUNET_OS_process_get_pid (pos->proc);
- ret = wait4 (pid, &status, WNOHANG, &ru);
+ pid = GNUNET_process_get_pid (pos->proc);
+ ret = wait4 (pid,
+ &status,
+ WNOHANG,
+ &ru);
if (ret <= 0)
continue; /* no process done */
if (WIFEXITED (status))
@@ -1769,10 +1770,13 @@ maint_child_death (void *cls)
}
else /* continue with JUST this "if" as "else" (intentionally no brackets!) */
#endif
- if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->proc,
- &statusType,
- &statusCode))) ||
- (ret == GNUNET_NO) || (statusType == GNUNET_OS_PROCESS_STOPPED) ||
+ if ((GNUNET_SYSERR ==
+ (ret = GNUNET_process_wait (pos->proc,
+ true,
+ &statusType,
+ &statusCode))) ||
+ (ret == GNUNET_NO) ||
+ (statusType == GNUNET_OS_PROCESS_STOPPED) ||
(statusType == GNUNET_OS_PROCESS_UNKNOWN) ||
(statusType == GNUNET_OS_PROCESS_RUNNING))
continue;
@@ -1801,9 +1805,11 @@ maint_child_death (void *cls)
GNUNET_TIME_absolute_get_duration (pos->killed_at),
GNUNET_YES));
}
- GNUNET_OS_process_destroy (pos->proc);
+ GNUNET_process_destroy (pos->proc);
pos->proc = NULL;
- broadcast_status (pos->name, GNUNET_ARM_SERVICE_STOPPED, NULL);
+ broadcast_status (pos->name,
+ GNUNET_ARM_SERVICE_STOPPED,
+ NULL);
if (NULL != pos->killing_client)
{
signal_result (pos->killing_client,
diff --git a/src/service/gns/gnunet-gns-import.c b/src/service/gns/gnunet-gns-import.c
@@ -18,7 +18,7 @@
SPDX-License-Identifier: AGPL3.0-or-later
*/
/**
- * @file gnunet-gns.c
+ * @file gnunet-gns-import.c
* @brief binary version of gnunet-gns-import.sh
* (for OSes that have no POSIX shell).
* @author LRN
@@ -88,22 +88,23 @@ static int ret;
static int
run_process_and_wait (enum GNUNET_OS_InheritStdioFlags std_inheritance,
- struct GNUNET_DISK_PipeHandle *pipe_stdin,
- struct GNUNET_DISK_PipeHandle *pipe_stdout,
enum GNUNET_OS_ProcessStatusType *st,
unsigned long *code,
const char *filename, ...)
{
- static struct GNUNET_OS_Process *p;
+ struct GNUNET_Process *p;
int arglen;
char *arg;
char *args;
char *argp;
va_list ap, apc1, apc2;
- va_start (ap, filename);
- va_copy (apc1, ap);
- va_copy (apc2, ap);
+ va_start (ap,
+ filename);
+ va_copy (apc1,
+ ap);
+ va_copy (apc2,
+ ap);
arglen = 0;
while (NULL != (arg = va_arg (apc1, char *)))
arglen += strlen (arg) + 1;
@@ -119,43 +120,47 @@ run_process_and_wait (enum GNUNET_OS_InheritStdioFlags std_inheritance,
va_end (apc2);
if (arglen > 0)
argp[-1] = '\0';
- p = GNUNET_OS_start_process_va (std_inheritance,
- pipe_stdin,
- pipe_stdout,
- NULL,
- filename, ap);
- va_end (ap);
- if (NULL == p)
+ p = GNUNET_process_create ();
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_set_options (
+ publish_proc,
+ GNUNET_process_option_std_inheritance (
+ std_inheritance)));
+ if (GNUNET_OK !=
+ GNUNET_process_set_command_ap (p,
+ filename,
+ ap))
{
+ va_end (ap);
+ GNUNET_process_destroy (p);
ret = 3;
- fprintf (stderr, "Failed to run `%s'\n", args);
- GNUNET_free (args);
- return 1;
- }
-
- if (GNUNET_OK != GNUNET_OS_process_wait (p))
- {
- ret = 4;
- fprintf (stderr, "Failed to wait for `%s'\n", args);
+ fprintf (stderr,
+ "Failed to run `%s'\n",
+ args);
GNUNET_free (args);
return 1;
}
+ va_end (ap);
- switch (GNUNET_OS_process_status (p, st, code))
+ switch (GNUNET_process_wait (p,
+ true,
+ st,
+ code))
{
case GNUNET_OK:
break;
-
case GNUNET_NO:
ret = 5;
- fprintf (stderr, "`%s' is still running\n", args);
+ fprintf (stderr,
+ "`%s' is still running\n",
+ args);
GNUNET_free (args);
return 1;
-
- default:
case GNUNET_SYSERR:
ret = 6;
- fprintf (stderr, "Failed to check the status of `%s'\n", args);
+ fprintf (stderr,
+ "Failed to check the status of `%s'\n",
+ args);
GNUNET_free (args);
return 1;
}
@@ -164,8 +169,10 @@ run_process_and_wait (enum GNUNET_OS_InheritStdioFlags std_inheritance,
static void
-check_pkey (unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd,
- char *pk, int *found_rec)
+check_pkey (unsigned int rd_len,
+ const struct GNUNET_GNSRECORD_Data *rd,
+ char *pk,
+ int *found_rec)
{
int i;
struct GNUNET_CRYPTO_BlindablePublicKey pubkey;
@@ -175,10 +182,11 @@ check_pkey (unsigned int rd_len, const struct GNUNET_GNSRECORD_Data *rd,
char *s;
if (sizeof (uint32_t) > rd[i].data_size)
continue;
- if (GNUNET_OK != GNUNET_GNSRECORD_identity_from_data (rd[i].data,
- rd[i].data_size,
- rd[i].record_type,
- &pubkey))
+ if (GNUNET_OK !=
+ GNUNET_GNSRECORD_identity_from_data (rd[i].data,
+ rd[i].data_size,
+ rd[i].record_type,
+ &pubkey))
continue;
s = GNUNET_GNSRECORD_value_to_string (rd[i].record_type,
rd[i].data,
@@ -227,7 +235,7 @@ zone_iteration_error (void *cls)
if (! found_private_rec)
{
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-namestore",
"gnunet-namestore", "-z", "master-zone",
"-a", "-e", "never", "-n", "private", "-p",
@@ -241,7 +249,7 @@ zone_iteration_error (void *cls)
if (! found_pin_rec)
{
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-namestore",
"gnunet-namestore", "-z", "master-zone",
"-a", "-e", "never", "-n", "pin", "-p", "-t",
@@ -389,7 +397,7 @@ run (void *cls, char *const *args, const char *cfgfile,
cfg = c;
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_NONE,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-arm",
"gnunet-arm", "-I", NULL))
{
@@ -400,60 +408,60 @@ run (void *cls, char *const *args, const char *cfgfile,
}
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-identity",
"gnunet-identity", "-C", "master-zone", NULL))
return;
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-identity",
"gnunet-identity", "-C", "private-zone", NULL))
return;
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-identity",
"gnunet-identity", "-C", "sks-zone", NULL))
return;
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-identity",
"gnunet-identity", "-e", "master-zone", "-s",
"gns-master", NULL))
return;
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-identity",
"gnunet-identity", "-e", "master-zone", "-s",
"namestore", NULL))
return;
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-identity",
"gnunet-identity", "-e", "master-zone", "-s",
"gns-proxy", NULL))
return;
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-identity",
"gnunet-identity", "-e", "master-zone", "-s",
"gns-intercept", NULL))
return;
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-identity",
"gnunet-identity", "-e", "private-zone", "-s",
"gns-private", NULL))
return;
if (0 != run_process_and_wait (GNUNET_OS_INHERIT_STD_OUT_AND_ERR,
- NULL, NULL, &st, &code,
+ &st, &code,
"gnunet-identity",
"gnunet-identity", "-e", "sks-zone", "-s",
"fs-sks", NULL))
@@ -480,9 +488,13 @@ main (int argc, char *const *argv)
};
int r;
- GNUNET_log_setup ("gnunet-gns-import", "WARNING", NULL);
+ GNUNET_log_setup ("gnunet-gns-import",
+ "WARNING",
+ NULL);
ret = 0;
- r = GNUNET_PROGRAM_run (argc, argv, "gnunet-gns-import",
+ r = GNUNET_PROGRAM_run (argc,
+ argv,
+ "gnunet-gns-import",
_ (
"This program will import some GNS authorities into your GNS namestore."),
options,
diff --git a/src/service/util/test_resolver_api.c b/src/service/util/test_resolver_api.c
@@ -337,47 +337,65 @@ main (int argc, char *argv[])
{
int ok = 1 + 2 + 4 + 8;
char *fn;
- struct GNUNET_OS_Process *proc;
+ struct GNUNET_Process *proc;
char *const argvx[] = {
(char*) "test-resolver-api",
(char*) "-c",
(char*) "test_resolver_api_data.conf",
NULL
};
- struct GNUNET_GETOPT_CommandLineOption options[] =
- { GNUNET_GETOPT_OPTION_END };
+ struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_OPTION_END
+ };
GNUNET_log_setup ("test-resolver-api",
"WARNING",
NULL);
fn = GNUNET_OS_get_libexec_binary_path (GNUNET_OS_project_data_gnunet (),
"gnunet-service-resolver");
- proc = GNUNET_OS_start_process (GNUNET_OS_INHERIT_STD_OUT_AND_ERR
- | GNUNET_OS_USE_PIPE_CONTROL,
- NULL, NULL, NULL,
- fn,
- "gnunet-service-resolver",
- "-c", "test_resolver_api_data.conf", NULL);
- GNUNET_assert (NULL != proc);
+ proc = GNUNET_process_create ();
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_set_options (
+ proc,
+ GNUNET_process_option_std_inheritance (
+ GNUNET_OS_INHERIT_STD_OUT_AND_ERR
+ | GNUNET_OS_USE_PIPE_CONTROL)));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_set_command_va (
+ proc,
+ fn,
+ "gnunet-service-resolver",
+ "-c", "test_resolver_api_data.conf",
+ NULL));
+ GNUNET_assert (GNUNET_OK ==
+ GNUNET_process_start (proc));
GNUNET_free (fn);
GNUNET_assert (GNUNET_OK ==
GNUNET_PROGRAM_run (GNUNET_OS_project_data_gnunet (),
(sizeof(argvx) / sizeof(char *)) - 1,
- argvx, "test-resolver-api", "nohelp",
+ argvx,
+ "test-resolver-api",
+ "nohelp",
options,
&run, &ok));
- if (0 != GNUNET_OS_process_kill (proc,
- GNUNET_TERM_SIG))
+ if (GNUNET_OK !=
+ GNUNET_process_kill (proc,
+ GNUNET_TERM_SIG))
{
GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING,
"kill");
ok = 1;
}
- GNUNET_OS_process_wait (proc);
- GNUNET_OS_process_destroy (proc);
+ GNUNET_process_wait (proc,
+ true,
+ NULL,
+ NULL);
+ GNUNET_process_destroy (proc);
proc = NULL;
if (0 != ok)
- fprintf (stderr, "Missed some resolutions: %u\n", ok);
+ fprintf (stderr,
+ "Missed some resolutions: %u\n",
+ ok);
return ok;
}