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

@@ -30,6 +30,10 @@
#include <iostream>
#include <stdlib.h>
#include <util.h>
#include <string.h>
#include <errno.h>
#include <text.h>
#include <i18n.h>
#include <Transport.h>
#include <TransportSSH.h>
#include <TransportRSYNC.h>
@@ -87,7 +91,17 @@ int Transport::execute()
it->append("\"");
}
}
return ::execute(_executable, _arguments);
int result = ::execute (_executable, _arguments);
int err;
switch (result) {
case 127:
throw format (STRING_TRANSPORT_NORUN, _executable);
case -1:
err = errno;
throw format (STRING_TRANSPORT_NOFORK, _executable, ::strerror(err));
default:
return result;
}
}
////////////////////////////////////////////////////////////////////////////////