From c9e3c29a259eeb8e1684993a30d2a06a153f5265 Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Fri, 21 Dec 2012 01:59:34 -0500 Subject: [PATCH] testsuite compiles on windows now (but doesn't work). Still need to implement bidirectional piping on stdout/stderr/stdin.. Which for some reason is incredibly stupidly complicated on windows. You need to setup SECURITY_ATTRIBUTES for each handle, do crazy handle duplication, and forking via CreateThread. Meanwhile the whole "concept" of threading is entierly broken in fundamental design on windows, which means you constantly need to store the current process handles for backup, and "inherit" from child process. It's just stupid, provide unix pipes via close/open and dup. Like normal people (they're simple and sane). --- test.c | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/test.c b/test.c index ed0abc1..0559e61 100644 --- a/test.c +++ b/test.c @@ -156,13 +156,40 @@ int task_pclose(FILE **handles) { return status; } #else +# define _WIN32_LEAN_AND_MEAN +# define popen _popen +# define pclose _pclose +# include +# include +# include + /* + * Bidirectional piping implementation for windows using CreatePipe and DuplicateHandle + + * other hacks. + */ + + typedef struct { + int __dummy; + /* TODO: implement */ + } popen_t; + + FILE **task_popen(const char *command, const char *mode) { + (void)command; + (void)mode; + + /* TODO: implement */ + return NULL; + } + + void task_pclose(FILE **files) { + /* TODO: implement */ + (void)files; + return; + } + # ifdef __MINGW32__ /* mingw32 has dirent.h */ # include # elif defined (_MSC_VER) -# define _WIN32_LEAN_AND_MEAN -# include -# include /* * visual studio lacks dirent.h it's a posix thing * so we emulate it with the WinAPI. @@ -235,6 +262,13 @@ int task_pclose(FILE **handles) { } return data; } + + /* + * Visual studio also lacks S_ISDIR for sys/stat.h, so we emulate this as well + * which is not hard at all. + */ +# undef S_ISDIR /* undef just incase */ +# define S_ISDIR(X) ((X)&_S_IFDIR) # endif #endif -- 2.39.2