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

Function worker_containment_unavailable

src/main.c:491–509  ·  view source on GitHub ↗

A worker that cannot contain its own process tree must not index: on failure * it would keep running as an orphan with no supervisor able to reap it. Shared * by the ordered containment steps in the worker path so all of them fail * identically — write() and _exit() rather than fprintf/exit, because this runs * after fork-sensitive setup and must not touch stdio locks or atexit handlers. */

Source from the content-addressed store, hash-verified

489 * after fork-sensitive setup and must not touch stdio locks or atexit handlers.
490 */
491static void worker_containment_unavailable(const char *why) {
492 /* WHICH of the containment conditions failed, and the pids behind it. The
493 * bare sentence cost a full CI cycle and two emulated builds to attribute
494 * (PR #2233): every venue reported the same line, and the supervisor only
495 * ever sees `killed (signal 9)` because the refusal SIGKILLs its own group.
496 * snprintf into a local buffer touches no stdio lock and no atexit handler,
497 * so the fork-sensitivity contract above still holds. */
498 char message[256];
499 int n = snprintf(message, sizeof(message),
500 "CBM index worker could not start: process-tree containment unavailable "
501 "(%s; pid=%ld pgrp=%ld ppid=%ld)\n",
502 why ? why : "unspecified", (long)getpid(), (long)getpgrp(), (long)getppid());
503 if (n > 0) {
504 (void)write(STDERR_FILENO, message,
505 (size_t)n < sizeof(message) ? (size_t)n : sizeof(message) - 1);
506 }
507 (void)kill(-getpid(), SIGKILL);
508 _exit(EXIT_FAILURE);
509}
510
511/* Test-only crash-orphan probe used by tests/test_worker_watchdog.sh. It is
512 * created before the watchdog thread so fork never occurs in a multithreaded

Callers 1

mainFunction · 0.85

Calls 2

_exitFunction · 0.85
writeFunction · 0.50

Tested by

no test coverage detected