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

Function cbm_subprocess_poll_win

src/foundation/subprocess.c:830–881  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

828}
829
830static cbm_proc_poll_t cbm_subprocess_poll_win(cbm_subprocess_t *process, cbm_proc_result_t *out) {
831 uint64_t now = cbm_now_ms();
832
833 if (!process->root_reaped) {
834 DWORD waited = WaitForSingleObject(process->process, 0);
835 if (waited == WAIT_OBJECT_0) {
836 DWORD code = 1;
837 (void)GetExitCodeProcess(process->process, &code);
838 cbm_win_capture_root(process, code);
839 } else if (waited == WAIT_FAILED) {
840 DWORD code = STILL_ACTIVE;
841 if (GetExitCodeProcess(process->process, &code) && code != STILL_ACTIVE) {
842 cbm_win_capture_root(process, code);
843 } else {
844 cbm_win_begin_termination(process, now);
845 cbm_win_force_tree(process, now);
846 }
847 }
848 }
849
850 bool job_known = false;
851 bool job_active = cbm_win_job_active(process, &job_known);
852 if (!process->termination_started) {
853 if (cbm_subprocess_cancellation_requested(process)) {
854 cbm_win_begin_termination(process, now);
855 } else if (!process->root_reaped && process->quiet_timeout_ms > 0 &&
856 now - process->last_activity_ms >= (uint64_t)process->quiet_timeout_ms) {
857 process->timed_out = true;
858 cbm_win_begin_termination(process, now);
859 } else if (process->root_reaped && job_active) {
860 /* Preserve the root's classification while draining escaped work. */
861 cbm_win_begin_termination(process, now);
862 }
863 }
864 if (!job_known) {
865 cbm_win_begin_termination(process, now);
866 cbm_win_force_tree(process, now);
867 }
868 if (process->termination_started && job_active && !process->force_sent &&
869 now - process->termination_started_ms >= (uint64_t)process->cancel_grace_ms) {
870 cbm_win_force_tree(process, now);
871 }
872 if (process->force_started_ms != 0 &&
873 now - process->force_started_ms >= CBM_SUBPROCESS_FORCE_SETTLE_MS &&
874 (!job_known || job_active || !process->root_reaped)) {
875 return cbm_subprocess_finish_failed(process, out);
876 }
877 if (process->root_reaped && !job_active) {
878 return cbm_subprocess_finish(process, out);
879 }
880 return CBM_PROC_POLL_RUNNING;
881}
882
883#else /* POSIX */
884

Callers 1

cbm_subprocess_pollFunction · 0.85

Calls 8

cbm_now_msFunction · 0.85
cbm_win_capture_rootFunction · 0.85
cbm_win_force_treeFunction · 0.85
cbm_win_job_activeFunction · 0.85
cbm_subprocess_finishFunction · 0.85

Tested by

no test coverage detected