From: Nathan S. Evans Date: Tue, 16 Feb 2010 12:25:45 +0000 (+0000) Subject: add stdin functionality for os start process function X-Git-Tag: initial-import-from-subversion-38251~22707 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9cd5c2637310df056f5f001ac0a505243b0d1f78;p=oweals%2Fgnunet.git add stdin functionality for os start process function --- diff --git a/src/util/os_priority.c b/src/util/os_priority.c index 9820592ac..26c76483c 100644 --- a/src/util/os_priority.c +++ b/src/util/os_priority.c @@ -127,6 +127,7 @@ pid_t GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNET_DISK_PipeHandle *pipe_stdout, const char *filename, ...) { /* FIXME: Make this work on windows!!! */ + /* FIXME: Make this work with stdin as well as stdout! */ va_list ap; #ifndef MINGW @@ -149,6 +150,8 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNE va_end (ap); if (pipe_stdout != NULL) GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle(pipe_stdout, GNUNET_DISK_PIPE_END_WRITE), &fd_stdout_write, sizeof (int)); + if (pipe_stdin != NULL) + GNUNET_DISK_internal_file_handle_ (GNUNET_DISK_pipe_handle(pipe_stdout, GNUNET_DISK_PIPE_END_READ), &fd_stdin_read, sizeof (int)); #if HAVE_WORKING_VFORK ret = vfork (); @@ -175,17 +178,26 @@ GNUNET_OS_start_process (struct GNUNET_DISK_PipeHandle *pipe_stdin, struct GNUNE sleep (1); if (pipe_stdout != NULL) GNUNET_DISK_pipe_close_end(pipe_stdout, GNUNET_DISK_PIPE_END_WRITE); + if (pipe_stdin != NULL) + GNUNET_DISK_pipe_close_end(pipe_stdin, GNUNET_DISK_PIPE_END_READ); #endif } GNUNET_free (argv); return ret; } + if (pipe_stdout != NULL) { dup2(fd_stdout_write, 1); close (fd_stdout_write); } + if (pipe_stdout != NULL) + { + dup2(fd_stdin_read, 0); + close (fd_stdin_read); + } + execvp (filename, argv); GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_ERROR, "execvp", filename); _exit (1);