diff --git a/connect.c b/connect.c index 64222f9ad9..3612c5538c 100644 --- a/connect.c +++ b/connect.c @@ -624,8 +624,11 @@ static void git_proxy_connect(int fd[2], char *host) { const char *argv[] = { NULL, host, port, NULL }; - spawnvpe_pipe(git_proxy_command, argv, environ, pipefd[1], pipefd[0]); + pid = spawnvpe_pipe(git_proxy_command, argv, environ, + pipefd[1], pipefd[0]); } + if (pid < 0) + die("fork failed"); fd[0] = pipefd[0][0]; fd[1] = pipefd[1][1]; } @@ -761,6 +764,8 @@ pid_t git_connect(int fd[2], char *url, const char *prog) env_unsetenv(env, INDEX_ENVIRONMENT); pid = spawnvpe_pipe("sh", argv, env, pipefd[1], pipefd[0]); } + if (pid < 0) + die("unable to fork"); fd[0] = pipefd[0][0]; fd[1] = pipefd[1][1]; if (free_path) diff --git a/diff.c b/diff.c index 12161b6f87..224d369288 100644 --- a/diff.c +++ b/diff.c @@ -1500,6 +1500,8 @@ static int spawn_prog(const char *pgm, const char **arg) fflush(NULL); pid = spawnvpe_pipe(pgm, arg, environ, NULL, NULL); + if (pid < 0) + die("unable to fork"); while (waitpid(pid, &status, 0) < 0) { if (errno == EINTR) diff --git a/merge-index.c b/merge-index.c index 6c2e00842e..bc85e35f4d 100644 --- a/merge-index.c +++ b/merge-index.c @@ -11,6 +11,9 @@ static void run_program(void) pid_t pid = spawnvpe_pipe(pgm, arguments, environ, NULL, NULL); int status; + if (pid < 0) + die("unable to fork"); + if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) { if (one_shot) { err++; diff --git a/spawn-pipe.c b/spawn-pipe.c index b4c2538b04..7d8aa7d6c7 100644 --- a/spawn-pipe.c +++ b/spawn-pipe.c @@ -198,9 +198,6 @@ int spawnvppe_pipe(const char *cmd, const char **argv, const char **env, pid = spawnvpe(_P_NOWAIT, interpr, qargv, env); } - if (pid < 0) - die("unable to run %s", cmd); - free(qargv); /* TODO: quoted args should be freed, too */ free(prog);