diff options
author | Johannes Sixt <j6t@kdbg.org> | 2010-03-06 16:40:42 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2010-03-07 00:37:36 -0800 |
commit | 200a76b74db5c2c75bcf73773cb85c5603ec038e (patch) | |
tree | 997a47438fe7e1ff3a9f649cc1f720c47dee4111 /run-command.h | |
parent | 912b26324dbc1eb9500e49c90d271a330cbcb30b (diff) | |
download | git-200a76b74db5c2c75bcf73773cb85c5603ec038e.tar.gz |
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 <j6t@kdbg.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'run-command.h')
-rw-r--r-- | run-command.h | 8 |
1 files changed, 6 insertions, 2 deletions
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 <pthread.h> +#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 |