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

Function wait_for_tree_pids

tests/test_subprocess.c:242–265  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240}
241
242static bool wait_for_tree_pids(const char *path, cbm_subprocess_t *process, pid_t *parent_pid,
243 pid_t *grandchild_pid, int timeout_ms) {
244 uint64_t deadline = cbm_now_ms() + (uint64_t)timeout_ms;
245 do {
246 FILE *f = fopen(path, "r");
247 if (f) {
248 long parent_value = 0;
249 long grandchild_value = 0;
250 int fields = fscanf(f, "%ld %ld", &parent_value, &grandchild_value);
251 fclose(f);
252 if (fields == 2 && parent_value > 1 && grandchild_value > 1) {
253 *parent_pid = (pid_t)parent_value;
254 *grandchild_pid = (pid_t)grandchild_value;
255 return true;
256 }
257 }
258 cbm_proc_result_t ignored;
259 if (cbm_subprocess_poll(process, &ignored) != CBM_PROC_POLL_RUNNING) {
260 return false;
261 }
262 subprocess_test_pause();
263 } while (cbm_now_ms() < deadline);
264 return false;
265}
266
267static bool wait_pid_gone(pid_t pid, int timeout_ms) {
268 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