2 * Actually start a process. All of the arguments given to this
3 * function are strings that are used for the "argv" array. However,
4 * if those strings contain spaces, the given argument is split into
5 * multiple argv entries without spaces. Similarly, if an argument is
6 * the empty string, it is skipped. This function has the inherent
7 * limitation that it does NOT allow passing command line arguments
8 * with spaces to the new process.
10 * @param first_arg first argument for argv (may be an empty string)
11 * @param ... more arguments, NULL terminated
12 * @return PID of the started process, -1 on error
15 do_start_process (const char *first_arg, ...)
19 unsigned int argv_size;
28 va_start (ap, first_arg);
44 if ( (last == NULL) && (*rpos != '\0') )
52 while (NULL != (arg = (va_arg (ap, const char*))));
55 argv = GNUNET_malloc (argv_size * sizeof (char *));
57 va_start (ap, first_arg);
62 cp = GNUNET_strdup (arg);
70 argv[argv_size++] = GNUNET_strdup (last);
76 if ( (last == NULL) && (*pos != '\0') )
82 argv[argv_size++] = GNUNET_strdup (last);
86 while (NULL != (arg = (va_arg (ap, const char*))));
88 argv[argv_size] = NULL;
89 pid = GNUNET_OS_start_process_v (argv[0], argv);
91 GNUNET_free (argv[--argv_size]);