Clean up Transport::execute() and callers.

- Ensure that the real exit code of the child program is retrieved
  using WEXITSTATUS().

- Centralise the handling of code 127, which means that the child
  shell process could not execute its child (ssh, rsync, or curl.)

Signed-off-by: Russell Steicke <russells@adelie.cx>
This commit is contained in:
Russell Steicke 2013-03-03 20:57:26 +08:00 committed by Paul Beckingham
parent 3dab5a1cb1
commit 1428a4135b
7 changed files with 41 additions and 33 deletions

View file

@ -417,7 +417,7 @@ int execute(const std::string& executable, std::vector<std::string> arguments)
cmdline += " " + (std::string)*it;
}
context.debug ("Executing: " + std::string(shell) + " " + std::string(opt) + " " + cmdline);
context.debug ("Executing: " + std::string(shell) + " " + std::string(opt) + " " + cmdline);
pid_t child_pid = fork();
@ -435,6 +435,10 @@ int execute(const std::string& executable, std::vector<std::string> arguments)
exit(ret);
}
else if (child_pid == -1)
{
return -1;
}
else
{
// this is done by the parent process
@ -445,7 +449,7 @@ int execute(const std::string& executable, std::vector<std::string> arguments)
if (pid == -1)
return -1;
else
return child_status;
return WEXITSTATUS (child_status);
}
}