MCPcopy Create free account
hub / github.com/AliveToolkit/alive2 / finishChild

Method finishChild

util/parallel.cpp:181–198  ·  view source on GitHub ↗

* if is_timeout is true, we in signal handling context and can only * call async-safe functions */

Source from the content-addressed store, hash-verified

179 * call async-safe functions
180 */
181void parallel::finishChild(bool is_timeout) {
182 ensureChild();
183 /*
184 * return the token before performing writes that may block. this
185 * results in a short-term load violation but also it prevents a
186 * deadlock
187 */
188 putToken();
189 if (is_timeout) {
190 const char *msg = "ERROR: Timeout asynchronous\n\n";
191 safe_write(fd_to_parent, msg, std::strlen(msg));
192 } else {
193 childProcess &me = children.back();
194 auto data = std::move(me.output).str();
195 auto size = data.size();
196 ENSURE(safe_write(me.pipe[1], data.c_str(), size) == (ssize_t)size);
197 }
198}
199
200void parallel::finishParent() {
201 ensureParent();

Callers 2

sigalarm_handlerFunction · 0.45
verifyMethod · 0.45

Calls 3

safe_writeFunction · 0.85
strMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected