DWORD stdif, stdof, stdef;
BOOL bresult;
DWORD error_code;
+ DWORD create_no_window;
if (GNUNET_SYSERR == GNUNET_OS_check_helper_binary (filename, GNUNET_NO, NULL))
return NULL; /* not executable */
return NULL;
}
+ create_no_window = 0;
+ {
+ HANDLE console_input = CreateFile ("CONIN$", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
+ if (INVALID_HANDLE_VALUE == console_input)
+ create_no_window = CREATE_NO_WINDOW;
+ else
+ CloseHandle (console_input);
+ }
+
bresult = CreateProcessW (wpath, wcmd, NULL, NULL, GNUNET_YES,
- CREATE_NO_WINDOW | CREATE_SUSPENDED, env_block, NULL, &start, &proc);
+ create_no_window | CREATE_SUSPENDED, env_block, NULL, &start, &proc);
error_code = GetLastError ();
if ((NULL == pipe_stdin) && (stdih))
return NULL;
}
- gnunet_proc = GNUNET_malloc (sizeof (struct GNUNET_OS_Process));
+ gnunet_proc = GNUNET_new (struct GNUNET_OS_Process);
gnunet_proc->pid = proc.dwProcessId;
gnunet_proc->handle = proc.hProcess;
gnunet_proc->control_pipe = childpipe_write;
/**
* Start a process. This function is similar to the GNUNET_OS_start_process_*
- * except that the @a filename and @argv can have whole strings which contain
+ * except that the filename and arguments can have whole strings which contain
* the arguments. These arguments are to be separated by spaces and are parsed
- * in the order they appear. Arguments containing spaces can be used by
+ * in the order they appear. Arguments containing spaces can be used by
* quoting them with @em ".
*
* @param pipe_control should a pipe be used to send signals to the child?
* must be NULL on platforms where dup is not supported
* @param filename name of the binary. It is valid to have the arguments
* in this string when they are separated by spaces.
- * @param ... more arguments. Should be of type <tt>char *</tt>. It is valid
+ * @param ... more arguments. Should be of type `char *`. It is valid
* to have the arguments in these strings when they are separated by
- * spaces.
- * @param argv NULL-terminated list of arguments to the process,
- * including the process name as the first argument
+ * spaces. The last argument MUST be NULL.
* @return pointer to process structure of the new process, NULL on error
*/
struct GNUNET_OS_Process *
GNUNET_OS_start_process_s (int pipe_control,
unsigned int std_inheritance,
const SOCKTYPE * lsocks,
- const char *first_arg, ...)
+ const char *filename, ...)
{
va_list ap;
char **argv;
size_t len;
argv_size = 1;
- va_start (ap, first_arg);
- arg = first_arg;
+ va_start (ap, filename);
+ arg = filename;
last = NULL;
do
{
quote_on = 0;
else
quote_on = 1;
- }
+ }
if ( (' ' == *rpos) && (0 == quote_on) )
{
if (NULL != last)
argv = GNUNET_malloc (argv_size * sizeof (char *));
argv_size = 0;
- va_start (ap, first_arg);
- arg = first_arg;
+ va_start (ap, filename);
+ arg = filename;
last = NULL;
do
{
quote_on = 0;
pos = cp;
while ('\0' != *pos)
- {
+ {
if ('"' == *pos)
{
if (1 == quote_on)
while (NULL != (arg = (va_arg (ap, const char*))));
va_end (ap);
argv[argv_size] = NULL;
-
+
for(i = 0; i < argv_size; i++)
{
len = strlen (argv[i]);
if ( (argv[i][0] == '"') && (argv[i][len-1] == '"'))
{
memmove (&argv[i][0], &argv[i][1], len - 2);
- argv[i][len-2] = '\0';
+ argv[i][len-2] = '\0';
}
}
binary_path = argv[0];
return NULL;
}
GNUNET_DISK_pipe_close_end (opipe, GNUNET_DISK_PIPE_END_WRITE);
- cmd = GNUNET_malloc (sizeof (struct GNUNET_OS_CommandHandle));
+ cmd = GNUNET_new (struct GNUNET_OS_CommandHandle);
cmd->timeout = GNUNET_TIME_relative_to_absolute (timeout);
cmd->eip = eip;
cmd->opipe = opipe;