|
@@ -1,6 +1,7 @@
|
|
|
#include "cache.h"
|
|
|
#include "run-command.h"
|
|
|
#include "exec_cmd.h"
|
|
|
+#include "debug.h"
|
|
|
|
|
|
static inline void close_pair(int fd[2])
|
|
|
{
|
|
@@ -19,6 +20,7 @@ int start_command(struct child_process *cmd)
|
|
|
{
|
|
|
int need_in, need_out, need_err;
|
|
|
int fdin[2], fdout[2], fderr[2];
|
|
|
+ char sbuf[STRERR_BUFSIZE];
|
|
|
|
|
|
/*
|
|
|
* In case of errors we must keep the promise to close FDs
|
|
@@ -99,7 +101,7 @@ int start_command(struct child_process *cmd)
|
|
|
|
|
|
if (cmd->dir && chdir(cmd->dir))
|
|
|
die("exec %s: cd to %s failed (%s)", cmd->argv[0],
|
|
|
- cmd->dir, strerror(errno));
|
|
|
+ cmd->dir, strerror_r(errno, sbuf, sizeof(sbuf)));
|
|
|
if (cmd->env) {
|
|
|
for (; *cmd->env; cmd->env++) {
|
|
|
if (strchr(*cmd->env, '='))
|
|
@@ -153,6 +155,8 @@ int start_command(struct child_process *cmd)
|
|
|
|
|
|
static int wait_or_whine(pid_t pid)
|
|
|
{
|
|
|
+ char sbuf[STRERR_BUFSIZE];
|
|
|
+
|
|
|
for (;;) {
|
|
|
int status, code;
|
|
|
pid_t waiting = waitpid(pid, &status, 0);
|
|
@@ -160,7 +164,8 @@ static int wait_or_whine(pid_t pid)
|
|
|
if (waiting < 0) {
|
|
|
if (errno == EINTR)
|
|
|
continue;
|
|
|
- error("waitpid failed (%s)", strerror(errno));
|
|
|
+ error("waitpid failed (%s)",
|
|
|
+ strerror_r(errno, sbuf, sizeof(sbuf)));
|
|
|
return -ERR_RUN_COMMAND_WAITPID;
|
|
|
}
|
|
|
if (waiting != pid)
|