From ae6a5609c025d9ac79e54a3a052704e25d885314 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Fri, 5 Feb 2010 12:57:38 -0800 Subject: run-command: support custom fd-set in async This patch adds the possibility to supply a set of non-0 file descriptors for async process communication instead of the default-created pipe. Additionally, we now support bi-directional communiction with the async procedure, by giving the async function both read and write file descriptors. To retain compatiblity and similar "API feel" with start_command, we require start_async callers to set .out = -1 to get a readable file descriptor. If either of .in or .out is 0, we supply no file descriptor to the async process. [sp: Note: Erik started this patch, and a huge bulk of it is his work. All bugs were introduced later by Shawn.] Signed-off-by: Erik Faye-Lund Signed-off-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- convert.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'convert.c') diff --git a/convert.c b/convert.c index 491e7141b4..e70ee094a7 100644 --- a/convert.c +++ b/convert.c @@ -241,7 +241,7 @@ struct filter_params { const char *cmd; }; -static int filter_buffer(int fd, void *data) +static int filter_buffer(int in, int out, void *data) { /* * Spawn cmd and feed the buffer contents through its stdin. @@ -254,7 +254,7 @@ static int filter_buffer(int fd, void *data) memset(&child_process, 0, sizeof(child_process)); child_process.argv = argv; child_process.in = -1; - child_process.out = fd; + child_process.out = out; if (start_command(&child_process)) return error("cannot fork to run external filter %s", params->cmd); @@ -291,6 +291,7 @@ static int apply_filter(const char *path, const char *src, size_t len, memset(&async, 0, sizeof(async)); async.proc = filter_buffer; async.data = ¶ms; + async.out = -1; params.src = src; params.size = len; params.cmd = cmd; -- cgit v1.2.1