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

Function mcp_command_output_path

src/mcp/mcp.c:9987–10018  ·  view source on GitHub ↗

Run shell-backed query helpers inside the same process-tree containment used * by indexing. A plain popen owns only its shell stream: on disconnect there is * no safe handle with which to stop a blocked git child or its descendants. */

Source from the content-addressed store, hash-verified

9985 * by indexing. A plain popen owns only its shell stream: on disconnect there is
9986 * no safe handle with which to stop a blocked git child or its descendants. */
9987static bool mcp_command_output_path(char out[CBM_SZ_2K]) {
9988 char directory[CBM_SZ_1K];
9989 const char *cache = cbm_resolve_cache_dir();
9990 int written;
9991 if (cache && cache[0]) {
9992 written = snprintf(directory, sizeof(directory), "%s/logs", cache);
9993 if (written <= 0 || written >= (int)sizeof(directory) || !cbm_mkdir_p(directory, 0700)) {
9994 return false;
9995 }
9996 } else {
9997 written = snprintf(directory, sizeof(directory), "%s", cbm_tmpdir());
9998 if (written <= 0 || written >= (int)sizeof(directory)) {
9999 return false;
10000 }
10001 }
10002 written = snprintf(out, CBM_SZ_2K, "%s/.mcp-command-XXXXXX", directory);
10003 if (written <= 0 || written >= CBM_SZ_2K) {
10004 out[0] = '\0';
10005 return false;
10006 }
10007 int descriptor = cbm_mkstemp(out);
10008 if (descriptor < 0) {
10009 out[0] = '\0';
10010 return false;
10011 }
10012#ifdef _WIN32
10013 (void)_close(descriptor);
10014#else
10015 (void)close(descriptor);
10016#endif
10017 return true;
10018}
10019
10020#ifdef _WIN32
10021/* Resolve the OS-owned command processor without consulting PATH or mutable

Callers 1

Calls 4

cbm_resolve_cache_dirFunction · 0.85
cbm_mkdir_pFunction · 0.85
cbm_tmpdirFunction · 0.85
cbm_mkstempFunction · 0.85

Tested by

no test coverage detected