MCPcopy Create free account
hub / github.com/apache/mesos / launch

Function launch

src/common/command_utils.cpp:44–105  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42namespace command {
43
44static Future<string> launch(
45 const string& path,
46 const vector<string>& argv)
47{
48 Try<Subprocess> s = subprocess(
49 path,
50 argv,
51 Subprocess::PATH(os::DEV_NULL),
52 Subprocess::PIPE(),
53 Subprocess::PIPE());
54
55 string command = strings::join(
56 ", ",
57 path,
58 strings::join(", ", argv));
59
60 if (s.isError()) {
61 return Failure(
62 "Failed to execute the subprocess '" + command + "': " + s.error());
63 }
64
65 return await(
66 s->status(),
67 process::io::read(s->out().get()),
68 process::io::read(s->err().get()))
69 .then([command](const tuple<
70 Future<Option<int>>,
71 Future<string>,
72 Future<string>>& t) -> Future<string> {
73 const Future<Option<int>>& status = std::get<0>(t);
74 if (!status.isReady()) {
75 return Failure(
76 "Failed to get the exit status of the subprocess: " +
77 (status.isFailed() ? status.failure() : "discarded"));
78 }
79
80 if (status->isNone()) {
81 return Failure("Failed to reap the subprocess");
82 }
83
84 if (status->get() != 0) {
85 const Future<string>& error = std::get<2>(t);
86 if (!error.isReady()) {
87 return Failure(
88 "Unexpected result from the subprocess: " +
89 WSTRINGIFY(status->get()) + ", stderr='" +
90 error.get() + "'");
91 }
92
93 return Failure("Subprocess '" + command + "' failed: " + error.get());
94 }
95
96 const Future<string>& output = std::get<1>(t);
97 if (!output.isReady()) {
98 return Failure(
99 "Failed to read stdout from '" + command + "': " +
100 (output.isFailed() ? output.failure() : "discarded"));
101 }

Callers 5

tarFunction · 0.70
untarFunction · 0.70
sha512Function · 0.70
gzipFunction · 0.70
decompressFunction · 0.70

Calls 15

FailureClass · 0.85
WSTRINGIFYFunction · 0.85
outMethod · 0.80
errMethod · 0.80
isReadyMethod · 0.80
isFailedMethod · 0.80
failureMethod · 0.80
errorMethod · 0.65
subprocessFunction · 0.50
joinFunction · 0.50
awaitFunction · 0.50
readFunction · 0.50

Tested by

no test coverage detected