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 PID of the started process, -1 on error
16 do_start_process (const int *lsocks,
17 const char *first_arg, ...)
21 unsigned int argv_size;
30 va_start (ap, first_arg);
46 if ( (last == NULL) && (*rpos != '\0') )
54 while (NULL != (arg = (va_arg (ap, const char*))));
57 argv = GNUNET_malloc (argv_size * sizeof (char *));
59 va_start (ap, first_arg);
64 cp = GNUNET_strdup (arg);
72 argv[argv_size++] = GNUNET_strdup (last);
78 if ( (last == NULL) && (*pos != '\0') )
84 argv[argv_size++] = GNUNET_strdup (last);
88 while (NULL != (arg = (va_arg (ap, const char*))));
90 argv[argv_size] = NULL;
91 pid = GNUNET_OS_start_process_v (lsocks, argv[0], argv);
93 GNUNET_free (argv[--argv_size]);