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

Function mcp_command_output_path

src/mcp/mcp.c:17125–17157  ·  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

17123 * by indexing. A plain popen owns only its shell stream: on disconnect there is
17124 * no safe handle with which to stop a blocked git child or its descendants. */
17125static bool mcp_command_output_path(char out[CBM_SZ_2K]) {
17126 char directory[CBM_SZ_1K];
17127 const char *cache = cbm_resolve_cache_dir();
17128 int written;
17129 if (cache && cache[0]) {
17130 written = snprintf(directory, sizeof(directory), "%s/logs", cache);
17131 if (written <= 0 || written >= (int)sizeof(directory) ||
17132 !cbm_mkdir_p_ex(directory, 0700, CBM_MKDIR_FOLLOW_OWNED)) {
17133 return false;
17134 }
17135 } else {
17136 written = snprintf(directory, sizeof(directory), "%s", cbm_tmpdir());
17137 if (written <= 0 || written >= (int)sizeof(directory)) {
17138 return false;
17139 }
17140 }
17141 written = snprintf(out, CBM_SZ_2K, "%s/.mcp-command-XXXXXX", directory);
17142 if (written <= 0 || written >= CBM_SZ_2K) {
17143 out[0] = '\0';
17144 return false;
17145 }
17146 int descriptor = cbm_mkstemp(out);
17147 if (descriptor < 0) {
17148 out[0] = '\0';
17149 return false;
17150 }
17151#ifdef _WIN32
17152 (void)_close(descriptor);
17153#else
17154 (void)close(descriptor);
17155#endif
17156 return true;
17157}
17158
17159#ifdef _WIN32
17160/* Resolve the OS-owned command processor without consulting PATH or mutable

Calls 5

cbm_resolve_cache_dirFunction · 0.85
cbm_mkdir_p_exFunction · 0.85
cbm_tmpdirFunction · 0.85
cbm_mkstempFunction · 0.85
closeFunction · 0.50

Tested by

no test coverage detected