Skip to content

Commit b5b56ea

Browse files
committed
Merge branch 'sb/run-command-fd-error-reporting'
* sb/run-command-fd-error-reporting: run-command: be more informative about what failed
2 parents f507784 + 939296c commit b5b56ea

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
@@ -274,6 +274,7 @@ int start_command(struct child_process *cmd)
274274
int need_in, need_out, need_err;
275275
int fdin[2], fdout[2], fderr[2];
276276
int failed_errno = failed_errno;
277+
char *str;
277278

278279
/*
279280
* In case of errors we must keep the promise to close FDs
@@ -286,6 +287,7 @@ int start_command(struct child_process *cmd)
286287
failed_errno = errno;
287288
if (cmd->out > 0)
288289
close(cmd->out);
290+
str = "standard input";
289291
goto fail_pipe;
290292
}
291293
cmd->in = fdin[1];
@@ -301,6 +303,7 @@ int start_command(struct child_process *cmd)
301303
close_pair(fdin);
302304
else if (cmd->in)
303305
close(cmd->in);
306+
str = "standard output";
304307
goto fail_pipe;
305308
}
306309
cmd->out = fdout[0];
@@ -318,9 +321,10 @@ int start_command(struct child_process *cmd)
318321
close_pair(fdout);
319322
else if (cmd->out)
320323
close(cmd->out);
324+
str = "standard error";
321325
fail_pipe:
322-
error("cannot create pipe for %s: %s",
323-
cmd->argv[0], strerror(failed_errno));
326+
error("cannot create %s pipe for %s: %s",
327+
str, cmd->argv[0], strerror(failed_errno));
324328
errno = failed_errno;
325329
return -1;
326330
}

0 commit comments

Comments
 (0)