MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / run_child

Function run_child

tests/test_coverage_children.c:294–328  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294static int run_child(const char *stem, const char *id, enum ChildOperation operation,
295 bool obstruct) {
296 Child child = {.id = id,
297 .operation = operation,
298 .obstruct = obstruct,
299 .pid = -1,
300 .ack = {-1, -1},
301 .gate = {-1, -1}};
302 const char *root = getenv("CBM_TEST_COVERAGE_DIR");
303 if (!root || root[0] != '/' || !child_runner || child_runner[0] != '/')
304 return 1;
305 struct sigaction ignore = {.sa_handler = SIG_IGN}, previous;
306 (void)sigemptyset(&ignore.sa_mask);
307 if (sigaction(SIGPIPE, &ignore, &previous) != 0)
308 return 1;
309 bool reaped = false;
310 int status = 0;
311 bool ok = start_child(&child, root) && ready_child(&child, root, stem) &&
312 finish_child(&child, &status, &reaped);
313 if (child.pid > 0 && !reaped && !reap(&child, true, &status, &reaped))
314 ok = false;
315 if (!close_fd(&child.ack[0]))
316 ok = false;
317 if (!close_fd(&child.ack[1]))
318 ok = false;
319 if (!close_fd(&child.gate[0]))
320 ok = false;
321 if (!close_fd(&child.gate[1]))
322 ok = false;
323 if (sigaction(SIGPIPE, &previous, NULL) != 0)
324 ok = false;
325 if (!ok)
326 fprintf(stderr, "coverage child fixture failed: %s\n", id);
327 return ok ? 0 : 1;
328}
329
330static int descriptor(const char *text) {
331 char *end = NULL;

Callers 1

Calls 6

start_childFunction · 0.85
ready_childFunction · 0.85
finish_childFunction · 0.85
sigactionClass · 0.70
reapFunction · 0.70
close_fdFunction · 0.70

Tested by

no test coverage detected