MCPcopy Create free account
hub / github.com/ElementsProject/lightning / try_opendir

Function try_opendir

ccan/ccan/closefrom/closefrom.c:120–136  ·  view source on GitHub ↗

It is possible that we run out of available file descriptors. * However, if we are going to close anyway, we could just try * closing file descriptors until we reach maxfd. */

Source from the content-addressed store, hash-verified

118 * closing file descriptors until we reach maxfd.
119 */
120static
121DIR *try_opendir(const char *dnam, int *fromfd, int maxfd)
122{
123 DIR *dir;
124
125 do {
126 dir = opendir(dnam);
127 if (!dir && (errno == ENFILE || errno == EMFILE)) {
128 if (*fromfd < maxfd)
129 close((*fromfd)++);
130 else
131 break;
132 }
133 } while (!dir && (errno == ENFILE || errno == EMFILE));
134
135 return dir;
136}
137
138void closefrom(int fromfd)
139{

Callers 1

closefromFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected