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

Function count_open_fds

src/foundation/diagnostics.c:100–126  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98/* ── FD count (platform-specific) ──────────────────────────────────────── */
99
100static int count_open_fds(void) {
101#ifdef __linux__
102 struct dirent **entries = NULL;
103 int n = scandir("/proc/self/fd", &entries, NULL, NULL);
104 if (n < 0) {
105 return CBM_NOT_FOUND;
106 }
107 for (int i = 0; i < n; i++) {
108 free(entries[i]);
109 }
110 free(entries);
111 return n - PAIR_LEN;
112#elif defined(__APPLE__)
113 struct dirent **entries = NULL;
114 int n = scandir("/dev/fd", &entries, NULL, NULL);
115 if (n < 0) {
116 return CBM_NOT_FOUND;
117 }
118 for (int i = 0; i < n; i++) {
119 free(entries[i]);
120 }
121 free(entries);
122 return n - PAIR_LEN;
123#else
124 return CBM_NOT_FOUND;
125#endif
126}
127
128/* ── Private output directory ────────────────────────────────────────────── */
129

Callers 1

write_diagnosticsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected