From 200a76b74db5c2c75bcf73773cb85c5603ec038e Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Sat, 6 Mar 2010 16:40:42 +0100 Subject: Reimplement async procedures using pthreads On Windows, async procedures have always been run in threads, and the implementation used Windows specific APIs. Rewrite the code to use pthreads. A new configuration option is introduced so that the threaded implementation can also be used on POSIX systems. Since this option is intended only as playground on POSIX, but is mandatory on Windows, the option is not documented. One detail is that on POSIX it is necessary to set FD_CLOEXEC on the pipe handles. On Windows, this is not needed because pipe handles are not inherited to child processes, and the new calls to set_cloexec() are effectively no-ops. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- run-command.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'run-command.h') diff --git a/run-command.h b/run-command.h index 94619f52d9..40db39cec0 100644 --- a/run-command.h +++ b/run-command.h @@ -1,6 +1,10 @@ #ifndef RUN_COMMAND_H #define RUN_COMMAND_H +#ifdef ASYNC_AS_THREAD +#include +#endif + struct child_process { const char **argv; pid_t pid; @@ -74,10 +78,10 @@ struct async { void *data; int in; /* caller writes here and closes it */ int out; /* caller reads from here and closes it */ -#ifndef WIN32 +#ifndef ASYNC_AS_THREAD pid_t pid; #else - HANDLE tid; + pthread_t tid; int proc_in; int proc_out; #endif -- cgit v1.2.1