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

Function mcp_command_output_path

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

14878 * by indexing. A plain popen owns only its shell stream: on disconnect there is
14879 * no safe handle with which to stop a blocked git child or its descendants. */
14880static bool mcp_command_output_path(char out[CBM_SZ_2K]) {
14881 char directory[CBM_SZ_1K];
14882 const char *cache = cbm_resolve_cache_dir();
14883 int written;
14884 if (cache && cache[0]) {
14885 written = snprintf(directory, sizeof(directory), "%s/logs", cache);
14886 if (written <= 0 || written >= (int)sizeof(directory) ||
14887 !cbm_mkdir_p_ex(directory, 0700, CBM_MKDIR_FOLLOW_OWNED)) {
14888 return false;
14889 }
14890 } else {
14891 written = snprintf(directory, sizeof(directory), "%s", cbm_tmpdir());
14892 if (written <= 0 || written >= (int)sizeof(directory)) {
14893 return false;
14894 }
14895 }
14896 written = snprintf(out, CBM_SZ_2K, "%s/.mcp-command-XXXXXX", directory);
14897 if (written <= 0 || written >= CBM_SZ_2K) {
14898 out[0] = '\0';
14899 return false;
14900 }
14901 int descriptor = cbm_mkstemp(out);
14902 if (descriptor < 0) {
14903 out[0] = '\0';
14904 return false;
14905 }
14906#ifdef _WIN32
14907 (void)_close(descriptor);
14908#else
14909 (void)close(descriptor);
14910#endif
14911 return true;
14912}
14913
14914#ifdef _WIN32
14915/* Resolve the OS-owned command processor without consulting PATH or mutable

Calls 4

cbm_resolve_cache_dirFunction · 0.85
cbm_mkdir_p_exFunction · 0.85
cbm_tmpdirFunction · 0.85
cbm_mkstempFunction · 0.85

Tested by

no test coverage detected