#include "platform.h"
#include "gnunet_util_lib.h"
-
/**
- * Global return value.
+ * Handler exit code
*/
-static int ret = 1;
+static long unsigned int exit_code = 1;
/**
* Helper process we started.
maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
{
enum GNUNET_OS_ProcessStatusType type;
- unsigned long code;
-
- if ( (GNUNET_OK ==
- GNUNET_OS_process_status (p, &type, &code)) &&
- (type == GNUNET_OS_PROCESS_EXITED) &&
- (0 == code) )
- ret = 0;
- else
- GNUNET_break (0 == GNUNET_OS_process_kill (p, SIGTERM));
+ if ( (GNUNET_OK !=
+ GNUNET_OS_process_status (p, &type, &exit_code)) ||
+ (type != GNUNET_OS_PROCESS_EXITED) )
+ GNUNET_break (0 == GNUNET_OS_process_kill (p, GNUNET_TERM_SIG));
GNUNET_OS_process_destroy (p);
}
rt = GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL,
GNUNET_DISK_pipe_handle (sigpipe,
GNUNET_DISK_PIPE_END_READ),
- &maint_child_death, NULL);
+ &maint_child_death, NULL);
p = GNUNET_OS_start_process (GNUNET_NO, 0,
- NULL, NULL,
+ NULL, NULL, NULL,
program,
program,
- args[0],
+ args[0],
NULL);
GNUNET_free (program);
if (NULL == p)
GNUNET_GETOPT_OPTION_END
};
struct GNUNET_SIGNAL_Context *shc_chld;
+ int ret;
if (GNUNET_OK != GNUNET_STRINGS_get_utf8_args (argc, argv, &argc, &argv))
return 2;
GNUNET_assert (sigpipe != NULL);
shc_chld =
GNUNET_SIGNAL_handler_install (GNUNET_SIGCHLD, &sighandler_child_death);
- if (GNUNET_OK !=
- GNUNET_PROGRAM_run (argc, argv, "gnunet-uri URI",
- gettext_noop ("Perform default-actions for GNUnet URIs"),
- options, &run, NULL))
- return 1;
+ ret = GNUNET_PROGRAM_run (argc, argv, "gnunet-uri URI",
+ gettext_noop ("Perform default-actions for GNUnet URIs"),
+ options, &run, NULL);
GNUNET_SIGNAL_handler_uninstall (shc_chld);
shc_chld = NULL;
GNUNET_DISK_pipe_close (sigpipe);
- sigpipe = NULL;
- return ret;
+ sigpipe = NULL;
+ GNUNET_free ((void *) argv);
+ return ((GNUNET_OK == ret) && (0 == exit_code)) ? 0 : 1;
}
/* end of gnunet-uri.c */