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

Function wait_for_tree_pids

tests/test_subprocess.c:281–304  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

279}
280
281static bool wait_for_tree_pids(const char *path, cbm_subprocess_t *process, pid_t *parent_pid,
282 pid_t *grandchild_pid, int timeout_ms) {
283 uint64_t deadline = cbm_now_ms() + (uint64_t)timeout_ms;
284 do {
285 FILE *f = fopen(path, "r");
286 if (f) {
287 long parent_value = 0;
288 long grandchild_value = 0;
289 int fields = fscanf(f, "%ld %ld", &parent_value, &grandchild_value);
290 fclose(f);
291 if (fields == 2 && parent_value > 1 && grandchild_value > 1) {
292 *parent_pid = (pid_t)parent_value;
293 *grandchild_pid = (pid_t)grandchild_value;
294 return true;
295 }
296 }
297 cbm_proc_result_t ignored;
298 if (cbm_subprocess_poll(process, &ignored) != CBM_PROC_POLL_RUNNING) {
299 return false;
300 }
301 subprocess_test_pause();
302 } while (cbm_now_ms() < deadline);
303 return false;
304}
305
306static bool wait_pid_gone(pid_t pid, int timeout_ms) {
307 uint64_t deadline = cbm_now_ms() + (uint64_t)timeout_ms;

Callers 1

test_subprocess.cFile · 0.85

Calls 3

cbm_now_msFunction · 0.85
cbm_subprocess_pollFunction · 0.85
subprocess_test_pauseFunction · 0.85

Tested by

no test coverage detected