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

Function cbm_pclose

src/foundation/compat_fs.c:393–417  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391}
392
393int cbm_pclose(FILE *f) {
394 InitOnceExecuteOnce(&g_popen_once, cbm_popen_init, NULL, NULL);
395
396 HANDLE proc = NULL;
397 EnterCriticalSection(&g_popen_lock);
398 for (int i = 0; i < CBM_POPEN_MAX; i++) {
399 if (g_popen_tab[i].fp == f) {
400 proc = g_popen_tab[i].proc;
401 g_popen_tab[i].fp = NULL;
402 g_popen_tab[i].proc = NULL;
403 break;
404 }
405 }
406 LeaveCriticalSection(&g_popen_lock);
407
408 if (!proc) {
409 return _pclose(f); /* opened via _popen (non-read mode) */
410 }
411 fclose(f);
412 WaitForSingleObject(proc, INFINITE);
413 DWORD code = 0;
414 BOOL got = GetExitCodeProcess(proc, &code);
415 CloseHandle(proc);
416 return got ? (int)code : -1;
417}
418
419FILE *cbm_fopen(const char *path, const char *mode) {
420 wchar_t *wpath = cbm_path_to_wide(path);

Callers 7

git_captureFunction · 0.85
fetch_latest_tagFunction · 0.85
handle_search_codeFunction · 0.85
parse_git_logFunction · 0.85
git_head_hashFunction · 0.85
ensure_gitattributesFunction · 0.85
test_security.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected