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 pipe_control should a pipe be used to send signals to the child?
11 * @param lsocks array of listen sockets to dup starting at fd3 (systemd-style), or NULL
12 * @param first_arg first argument for argv (may be an empty string)
13 * @param ... more arguments, NULL terminated
14 * @return handle of the started process, NULL on error
16 static struct GNUNET_OS_Process *
17 do_start_process (int pipe_control,
18 const SOCKTYPE * lsocks, const char *first_arg, ...)
22 unsigned int argv_size;
28 struct GNUNET_OS_Process *proc;
31 va_start (ap, first_arg);
49 if ((last == NULL) && (*rpos != '\0'))
58 while (NULL != (arg = (va_arg (ap, const char*))));
62 argv = GNUNET_malloc (argv_size * sizeof (char *));
64 va_start (ap, first_arg);
71 cp = GNUNET_strdup (arg);
79 argv[argv_size++] = GNUNET_strdup (last);
85 if ((last == NULL) && (*pos != '\0'))
91 argv[argv_size++] = GNUNET_strdup (last);
96 while (NULL != (arg = (va_arg (ap, const char*))));
99 argv[argv_size] = NULL;
100 proc = GNUNET_OS_start_process_v (pipe_control, lsocks, argv[0], argv);
101 while (argv_size > 0)
102 GNUNET_free (argv[--argv_size]);