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 lsocks array of listen sockets to dup starting at fd3 (systemd-style), or NULL
11 * @param first_arg first argument for argv (may be an empty string)
12 * @param ... more arguments, NULL terminated
13 * @return handle of the started process, NULL on error
15 static struct GNUNET_OS_Process *
16 do_start_process (const SOCKTYPE * lsocks, const char *first_arg, ...)
20 unsigned int argv_size;
26 struct GNUNET_OS_Process *proc;
29 va_start (ap, first_arg);
47 if ((last == NULL) && (*rpos != '\0'))
56 while (NULL != (arg = (va_arg (ap, const char*))));
60 argv = GNUNET_malloc (argv_size * sizeof (char *));
62 va_start (ap, first_arg);
69 cp = GNUNET_strdup (arg);
77 argv[argv_size++] = GNUNET_strdup (last);
83 if ((last == NULL) && (*pos != '\0'))
89 argv[argv_size++] = GNUNET_strdup (last);
94 while (NULL != (arg = (va_arg (ap, const char*))));
97 argv[argv_size] = NULL;
98 proc = GNUNET_OS_start_process_v (lsocks, argv[0], argv);
100 GNUNET_free (argv[--argv_size]);