MCPcopy Create free account
hub / github.com/F-Stack/f-stack / anetCloexec

Function anetCloexec

app/redis-6.2.6/src/anet.c:110–128  ·  view source on GitHub ↗

Enable the FD_CLOEXEC on the given fd to avoid fd leaks. * This function should be invoked for fd's on specific places * where fork + execve system calls are called. */

Source from the content-addressed store, hash-verified

108 * This function should be invoked for fd's on specific places
109 * where fork + execve system calls are called. */
110int anetCloexec(int fd) {
111 int r;
112 int flags;
113
114 do {
115 r = fcntl(fd, F_GETFD);
116 } while (r == -1 && errno == EINTR);
117
118 if (r == -1 || (r & FD_CLOEXEC))
119 return r;
120
121 flags = r | FD_CLOEXEC;
122
123 do {
124 r = fcntl(fd, F_SETFD, flags);
125 } while (r == -1 && errno == EINTR);
126
127 return r;
128}
129
130/* Set TCP keep alive option to detect dead peers. The interval option
131 * is only used for Linux as we are using Linux-specific APIs to set

Callers 11

aeApiCreateFunction · 0.85
listenToPortFunction · 0.85
initServerFunction · 0.85
acceptTcpHandlerFunction · 0.85
acceptTLSHandlerFunction · 0.85
acceptUnixHandlerFunction · 0.85
aeApiCreateFunction · 0.85
moduleInitModulesSystemFunction · 0.85
aeApiCreateFunction · 0.85
aeApiCreateFunction · 0.85

Calls 1

fcntlFunction · 0.70

Tested by

no test coverage detected