2 #include "gnunet_util_lib.h"
6 * Generic logging shorthand
8 #define LOG(kind,...) \
9 fprintf (stderr, __VA_ARGS__)
12 * Debug logging shorthand
14 #define LOG_DEBUG(...) \
15 LOG (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__)
24 * Execution start point
27 main (int argc, char *argv[])
29 static const struct GNUNET_GETOPT_CommandLineOption options[] = {
30 GNUNET_GETOPT_OPTION_END
32 struct GNUNET_OS_Process *proc;
35 enum GNUNET_OS_ProcessStatusType proc_status;
44 printf ("Need arguments: gnunet-testbed-mpi-spawn <cmd> <cmd_args>");
47 if (MPI_SUCCESS != MPI_Init (&argc, &argv))
52 if (MPI_SUCCESS != MPI_Comm_rank (MPI_COMM_WORLD, &rank))
56 (void) MPI_Finalize ();
62 (void) MPI_Finalize ();
65 (void) MPI_Finalize ();
66 PRINTF ("Spawning process\n");
67 argv2 = GNUNET_malloc (sizeof (char *) * argc);
68 for (cnt = 1; cnt < argc; cnt++)
69 argv2[cnt - 1] = argv[cnt];
71 GNUNET_OS_start_process_vap (GNUNET_NO, GNUNET_OS_INHERIT_STD_ALL, NULL,
72 NULL, argv2[0], argv2);
75 LOG (GNUNET_ERROR_TYPE_ERROR, "Cannot exec\n");
82 chstat = GNUNET_OS_process_status (proc, &proc_status, &code);
84 while (GNUNET_NO == chstat);
85 if (GNUNET_OK != chstat)
92 LOG (GNUNET_ERROR_TYPE_WARNING, "Child terminated abnormally\n");
93 ret = 50 + (int) code;
100 LOG (GNUNET_ERROR_TYPE_ERROR, "Something went wrong. Error: %d\n", ret);