[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r12992 - gnunet/src/util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r12992 - gnunet/src/util |
Date: |
Wed, 15 Sep 2010 10:31:21 +0200 |
Author: wachs
Date: 2010-09-15 10:31:21 +0200 (Wed, 15 Sep 2010)
New Revision: 12992
Modified:
gnunet/src/util/Makefile.am
gnunet/src/util/disk.c
gnunet/src/util/scheduler.c
gnunet/src/util/test_os_start_process.c
gnunet/src/util/test_scheduler.c
Log:
0001602: A patch to fix process spawning with redirected std streams
Modified: gnunet/src/util/Makefile.am
===================================================================
--- gnunet/src/util/Makefile.am 2010-09-15 08:28:48 UTC (rev 12991)
+++ gnunet/src/util/Makefile.am 2010-09-15 08:31:21 UTC (rev 12992)
@@ -14,6 +14,8 @@
-lshell32 -liconv -lstdc++ \
-lcomdlg32 -lgdi32
WINLIB = libgnunetutilwin.la
+noinst_PROGRAMS = test_os_start_process_cat
+ test_os_start_process_cat_SOURCES = test_os_start_process_cat.c
endif
if USE_COVERAGE
Modified: gnunet/src/util/disk.c
===================================================================
--- gnunet/src/util/disk.c 2010-09-15 08:28:48 UTC (rev 12991)
+++ gnunet/src/util/disk.c 2010-09-15 08:31:21 UTC (rev 12992)
@@ -1649,7 +1649,7 @@
* @return handle to the new pipe, NULL on error
*/
struct GNUNET_DISK_PipeHandle *
-GNUNET_DISK_pipe (int blocking)
+GNUNET_DISK_pipe (int blocking, int inherit_read, int inherit_write)
{
struct GNUNET_DISK_PipeHandle *p;
struct GNUNET_DISK_FileHandle *fds;
@@ -1699,6 +1699,7 @@
}
#else
BOOL ret;
+ HANDLE tmp_handle;
ret = CreatePipe (&p->fd[0]->h, &p->fd[1]->h, NULL, 0);
if (!ret)
@@ -1707,6 +1708,31 @@
SetErrnoFromWinError (GetLastError ());
return NULL;
}
+ if (!DuplicateHandle (GetCurrentProcess (), p->fd[0]->h,
+ GetCurrentProcess (), &tmp_handle, 0, inherit_read ==
GNUNET_YES ? TRUE : FALSE,
+ DUPLICATE_SAME_ACCESS))
+ {
+ SetErrnoFromWinError (GetLastError ());
+ CloseHandle (p->fd[0]->h);
+ CloseHandle (p->fd[1]->h);
+ GNUNET_free (p);
+ return NULL;
+ }
+ CloseHandle (p->fd[0]->h);
+ p->fd[0]->h = tmp_handle;
+
+ if (!DuplicateHandle (GetCurrentProcess (), p->fd[1]->h,
+ GetCurrentProcess (), &tmp_handle, 0, inherit_write ==
GNUNET_YES ? TRUE : FALSE,
+ DUPLICATE_SAME_ACCESS))
+ {
+ SetErrnoFromWinError (GetLastError ());
+ CloseHandle (p->fd[0]->h);
+ CloseHandle (p->fd[1]->h);
+ GNUNET_free (p);
+ return NULL;
+ }
+ CloseHandle (p->fd[1]->h);
+ p->fd[1]->h = tmp_handle;
if (!blocking)
{
DWORD mode;
Modified: gnunet/src/util/scheduler.c
===================================================================
--- gnunet/src/util/scheduler.c 2010-09-15 08:28:48 UTC (rev 12991)
+++ gnunet/src/util/scheduler.c 2010-09-15 08:31:21 UTC (rev 12992)
@@ -749,7 +749,7 @@
rs = GNUNET_NETWORK_fdset_create ();
ws = GNUNET_NETWORK_fdset_create ();
GNUNET_assert (shutdown_pipe_handle == NULL);
- shutdown_pipe_handle = GNUNET_DISK_pipe (GNUNET_NO);
+ shutdown_pipe_handle = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO);
GNUNET_assert (shutdown_pipe_handle != NULL);
pr = GNUNET_DISK_pipe_handle (shutdown_pipe_handle,
GNUNET_DISK_PIPE_END_READ);
GNUNET_assert (pr != NULL);
Modified: gnunet/src/util/test_os_start_process.c
===================================================================
--- gnunet/src/util/test_os_start_process.c 2010-09-15 08:28:48 UTC (rev
12991)
+++ gnunet/src/util/test_os_start_process.c 2010-09-15 08:31:21 UTC (rev
12992)
@@ -105,11 +105,14 @@
char *fn;
const struct GNUNET_DISK_FileHandle *stdout_read_handle;
const struct GNUNET_DISK_FileHandle *wh;
-
+#ifndef WINDOWS
GNUNET_asprintf(&fn, "cat");
+#else
+ GNUNET_asprintf(&fn, "./.libs/test_os_start_process_cat.exe");
+#endif
- hello_pipe_stdin = GNUNET_DISK_pipe(GNUNET_YES);
- hello_pipe_stdout = GNUNET_DISK_pipe(GNUNET_YES);
+ hello_pipe_stdin = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_YES, GNUNET_NO);
+ hello_pipe_stdout = GNUNET_DISK_pipe (GNUNET_YES, GNUNET_NO, GNUNET_YES);
if ((hello_pipe_stdout == NULL) || (hello_pipe_stdin == NULL))
{
Modified: gnunet/src/util/test_scheduler.c
===================================================================
--- gnunet/src/util/test_scheduler.c 2010-09-15 08:28:48 UTC (rev 12991)
+++ gnunet/src/util/test_scheduler.c 2010-09-15 08:31:21 UTC (rev 12992)
@@ -114,7 +114,7 @@
int *ok = cls;
GNUNET_assert (5 == *ok);
(*ok) = 6;
- p = GNUNET_DISK_pipe (GNUNET_NO);
+ p = GNUNET_DISK_pipe (GNUNET_NO, GNUNET_NO, GNUNET_NO);
GNUNET_assert (NULL != p);
fds[0] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_READ);
fds[1] = GNUNET_DISK_pipe_handle (p, GNUNET_DISK_PIPE_END_WRITE);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r12992 - gnunet/src/util,
gnunet <=