[PATCH 04/14] Use run_command() to spawn external diff programs instead of fork/exec.

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <gitster@...>
Cc: <git@...>, Johannes Sixt <johannes.sixt@...>
Date: Saturday, October 13, 2007 - 4:06 pm

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
---
 diff.c |   38 +++-----------------------------------
 1 files changed, 3 insertions(+), 35 deletions(-)

diff --git a/diff.c b/diff.c
index 0ee9ea1..d03dc6a 100644
--- a/diff.c
+++ b/diff.c
@@ -9,6 +9,7 @@
 #include "xdiff-interface.h"
 #include "color.h"
 #include "attr.h"
+#include "run-command.h"
 
 #ifdef NO_FAST_WORKING_DIRECTORY
 #define FAST_WORKING_DIRECTORY 0
@@ -1791,40 +1792,6 @@ static void remove_tempfile_on_signal(int signo)
 	raise(signo);
 }
 
-static int spawn_prog(const char *pgm, const char **arg)
-{
-	pid_t pid;
-	int status;
-
-	fflush(NULL);
-	pid = fork();
-	if (pid < 0)
-		die("unable to fork");
-	if (!pid) {
-		execvp(pgm, (char *const*) arg);
-		exit(255);
-	}
-
-	while (waitpid(pid, &status, 0) < 0) {
-		if (errno == EINTR)
-			continue;
-		return -1;
-	}
-
-	/* Earlier we did not check the exit status because
-	 * diff exits non-zero if files are different, and
-	 * we are not interested in knowing that.  It was a
-	 * mistake which made it harder to quit a diff-*
-	 * session that uses the git-apply-patch-script as
-	 * the GIT_EXTERNAL_DIFF.  A custom GIT_EXTERNAL_DIFF
-	 * should also exit non-zero only when it wants to
-	 * abort the entire diff-* session.
-	 */
-	if (WIFEXITED(status) && !WEXITSTATUS(status))
-		return 0;
-	return -1;
-}
-
 /* An external diff command takes:
  *
  * diff-cmd name infile1 infile1-sha1 infile1-mode \
@@ -1877,7 +1844,8 @@ static void run_external_diff(const char *pgm,
 		*arg++ = name;
 	}
 	*arg = NULL;
-	retval = spawn_prog(pgm, spawn_arg);
+	fflush(NULL);
+	retval = run_command_v_opt(spawn_arg, 0);
 	remove_tempfile();
 	if (retval) {
 		fprintf(stderr, "external diff died, stopping at %s.\n", name);
-- 
1.5.3.3.1134.gee562

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/14] fork/exec removal series, Johannes Sixt, (Sat Oct 13, 4:06 pm)
Re: [PATCH 0/14] fork/exec removal series, Shawn O. Pearce, (Sat Oct 13, 10:11 pm)
Re: [PATCH 0/14] fork/exec removal series, Johannes Schindelin, (Sat Oct 13, 10:50 pm)
Re: [PATCH 0/14] fork/exec removal series, Shawn O. Pearce, (Sat Oct 13, 10:58 pm)
Re: [PATCH 0/14] fork/exec removal series, Pierre Habouzit, (Sun Oct 14, 3:12 am)
Re: [PATCH 0/14] fork/exec removal series, Johannes Schindelin, (Sun Oct 14, 1:09 pm)
Re: [PATCH 0/14] fork/exec removal series, Pierre Habouzit, (Sun Oct 14, 3:17 am)
Re: [PATCH 0/14] fork/exec removal series, Pierre Habouzit, (Sun Oct 14, 3:28 am)
Re: [PATCH 0/14] fork/exec removal series, Andreas Ericsson, (Sun Oct 14, 5:10 am)
Re: [PATCH 01/14] Change git_connect() to return a struct ch..., Johannes Schindelin, (Sat Oct 13, 8:57 pm)
Re: [PATCH 01/14] Change git_connect() to return a struct ch..., Johannes Schindelin, (Sun Oct 14, 1:10 pm)
[PATCH 04/14] Use run_command() to spawn external diff progr..., Johannes Sixt, (Sat Oct 13, 4:06 pm)