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

Function subprocess_expected_close_strategy

tests/test_subprocess.c:1333–1344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1331}
1332
1333static cbm_fd_close_strategy_t subprocess_expected_close_strategy(void) {
1334#if defined(__linux__) && defined(SYS_close_range)
1335 /* Probe the kernel on an empty range: an old kernel (< 5.9) or a seccomp
1336 * filter without it answers ENOSYS/EPERM, and then the loop is correct. */
1337 long probe = syscall(SYS_close_range, ~0U, ~0U, 0U);
1338 return (probe == 0 || errno == EINVAL) ? CBM_FD_CLOSE_RANGE : CBM_FD_CLOSE_LOOP;
1339#elif defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__) || defined(__DragonFly__)
1340 return CBM_FD_CLOSEFROM;
1341#else
1342 return CBM_FD_CLOSE_LOOP;
1343#endif
1344}
1345
1346/* Park two non-CLOEXEC descriptors near the top of the table; returns the lower
1347 * of the two and hands back the original (low) descriptor in *keep_low. The

Callers 1

test_subprocess.cFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected