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

Method execute

src/linux/perf.cpp:126–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124
125private:
126 void execute()
127 {
128 // NOTE: The supervisor childhook places perf in its own process group
129 // and will kill the perf process when the parent dies.
130 Try<Subprocess> _perf = subprocess(
131 "perf",
132 argv,
133 Subprocess::PIPE(),
134 Subprocess::PIPE(),
135 Subprocess::PIPE(),
136 nullptr,
137 None(),
138 None(),
139 {},
140 {Subprocess::ChildHook::SUPERVISOR()});
141
142 if (_perf.isError()) {
143 promise.fail("Failed to launch perf process: " + _perf.error());
144 terminate(self());
145 return;
146 }
147 perf = _perf.get();
148
149 // Wait for the process to exit.
150 await(perf->status(),
151 io::read(perf->out().get()),
152 io::read(perf->err().get()))
153 .onReady(defer(self(), [this](const tuple<
154 Future<Option<int>>,
155 Future<string>,
156 Future<string>>& results) {
157 const Future<Option<int>>& status = std::get<0>(results);
158 const Future<string>& output = std::get<1>(results);
159
160 Option<Error> error = None();
161
162 if (!status.isReady()) {
163 error = Error("Failed to execute perf: " +
164 (status.isFailed() ? status.failure() : "discarded"));
165 } else if (status->isNone()) {
166 error = Error("Failed to execute perf: failed to reap");
167 } else if (status->get() != 0) {
168 error = Error("Failed to execute perf: " +
169 WSTRINGIFY(status->get()));
170 } else if (!output.isReady()) {
171 error = Error("Failed to read perf output: " +
172 (output.isFailed() ? output.failure() : "discarded"));
173 }
174
175 if (error.isSome()) {
176 promise.fail(error->message);
177 terminate(self());
178 return;
179 }
180
181 promise.set(output.get());
182 terminate(self());
183 return;

Callers

nothing calls this directly

Calls 15

NoneClass · 0.85
deferFunction · 0.85
WSTRINGIFYFunction · 0.85
outMethod · 0.80
errMethod · 0.80
isReadyMethod · 0.80
isFailedMethod · 0.80
failureMethod · 0.80
readFunction · 0.70
errorMethod · 0.65
subprocessFunction · 0.50
terminateFunction · 0.50

Tested by

no test coverage detected