Skip to content

Commit 939296c

Browse files
bebarinogitster
authored andcommitted
run-command: be more informative about what failed
While debugging an error with verify_signed_buffer() the error messages from run-command weren't very useful: error: cannot create pipe for gpg: Too many open files error: could not run gpg. because they didn't indicate *which* pipe couldn't be created. Print which pipe failed to be created in the error message so we can more easily debug similar problems in the future. For example, the above error now prints: error: cannot create standard error pipe for gpg: Too many open files error: could not run gpg. Signed-off-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7e20105 commit 939296c

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

run-command.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ int start_command(struct child_process *cmd)
273273
int need_in, need_out, need_err;
274274
int fdin[2], fdout[2], fderr[2];
275275
int failed_errno = failed_errno;
276+
char *str;
276277

277278
/*
278279
* In case of errors we must keep the promise to close FDs
@@ -285,6 +286,7 @@ int start_command(struct child_process *cmd)
285286
failed_errno = errno;
286287
if (cmd->out > 0)
287288
close(cmd->out);
289+
str = "standard input";
288290
goto fail_pipe;
289291
}
290292
cmd->in = fdin[1];
@@ -300,6 +302,7 @@ int start_command(struct child_process *cmd)
300302
close_pair(fdin);
301303
else if (cmd->in)
302304
close(cmd->in);
305+
str = "standard output";
303306
goto fail_pipe;
304307
}
305308
cmd->out = fdout[0];
@@ -317,9 +320,10 @@ int start_command(struct child_process *cmd)
317320
close_pair(fdout);
318321
else if (cmd->out)
319322
close(cmd->out);
323+
str = "standard error";
320324
fail_pipe:
321-
error("cannot create pipe for %s: %s",
322-
cmd->argv[0], strerror(failed_errno));
325+
error("cannot create %s pipe for %s: %s",
326+
str, cmd->argv[0], strerror(failed_errno));
323327
errno = failed_errno;
324328
return -1;
325329
}

0 commit comments

Comments
 (0)