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

Function count_open_fds

src/foundation/diagnostics.c:101–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

write_diagnosticsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected