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

Function run_on_worker_stack

tests/test_cypher.c:5180–5205  ·  view source on GitHub ↗

Runs check(arg) the way the daemon runs a query. POSIX: on the worker-sized * thread of a forked child, whose exit status is the check's result; a killing * signal is reported as such. Windows has no fork, and CreateThread's size * argument sets the committed stack while the reserve stays the image default, * so the thread runs in-process there. */

Source from the content-addressed store, hash-verified

5178 * argument sets the committed stack while the reserve stays the image default,
5179 * so the thread runs in-process there. */
5180static int run_on_worker_stack(int (*check)(void *), void *arg) {
5181 worker_stack_run_t run = {.check = check, .arg = arg, .result = 1};
5182#ifdef _WIN32
5183 return run_on_worker_stack_thread(&run);
5184#else
5185 fflush(NULL);
5186 pid_t pid = fork();
5187 if (pid == 0) {
5188 int code = run_on_worker_stack_thread(&run);
5189 fflush(NULL);
5190 _exit(code == 0 ? 0 : 1);
5191 }
5192 ASSERT_TRUE(pid > 0);
5193 int status = 0;
5194 (void)waitpid(pid, &status, 0);
5195 if (WIFSIGNALED(status)) {
5196 char m[96];
5197 snprintf(m, sizeof(m), "query thread killed by signal %d on a %d KiB stack",
5198 WTERMSIG(status), CYPHER_WORKER_STACK_BYTES / 1024);
5199 FAIL(m);
5200 }
5201 ASSERT_TRUE(WIFEXITED(status));
5202 ASSERT_EQ(WEXITSTATUS(status), 0);
5203 return 0;
5204#endif
5205}
5206
5207/* The fixture graph of setup_cypher_store, restated here so the expected rows
5208 * are computed by the test and not read back from the engine. */

Callers 1

test_cypher.cFile · 0.85

Calls 2

_exitFunction · 0.85

Tested by

no test coverage detected