Use symbolic name for FD_CLOEXEC

Unsure why I was using ‘1’ — perhaps the symbolic name was missing in the older SDK.
This commit is contained in:
Allan Odgaard
2012-08-23 20:28:54 +02:00
parent f5c7301ba7
commit 3415d775c5
7 changed files with 11 additions and 11 deletions

View File

@@ -136,7 +136,7 @@ namespace
}
socket_t fd(socket(AF_UNIX, SOCK_STREAM, 0));
fcntl(fd, F_SETFD, 1);
fcntl(fd, F_SETFD, FD_CLOEXEC);
struct sockaddr_un addr = { 0, AF_UNIX };
strcpy(addr.sun_path, _socket_path);
addr.sun_len = SUN_LEN(&addr);
@@ -169,7 +169,7 @@ namespace
socket_t fd(socket(AF_INET, SOCK_STREAM, 0));
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
fcntl(fd, F_SETFD, 1);
fcntl(fd, F_SETFD, FD_CLOEXEC);
struct sockaddr_in iaddr = { sizeof(sockaddr_in), AF_INET, htons(_port), { htonl(_ip) } };
if(-1 == bind(fd, (sockaddr*)&iaddr, sizeof(iaddr)))
fprintf(stderr, "bind(): %s\n", strerror(errno));

View File

@@ -31,7 +31,7 @@ namespace
{
client_key = server().register_client(this);
int newFd = dup(fd);
fcntl(newFd, F_SETFD, 1);
fcntl(newFd, F_SETFD, FD_CLOEXEC);
server().send_request(client_key, (request_t){ newFd, str });
}

View File

@@ -67,7 +67,7 @@ namespace filter
{
_client_key = write_server().register_client(this);
int newFd = dup(fd);
fcntl(newFd, F_SETFD, 1);
fcntl(newFd, F_SETFD, FD_CLOEXEC);
write_server().send_request(_client_key, (request_t){ newFd, bytes });
}

View File

@@ -10,8 +10,8 @@ namespace io
write_pipe = pipes[1];
if(close_on_exec)
{
fcntl(pipes[0], F_SETFD, 1);
fcntl(pipes[1], F_SETFD, 1);
fcntl(pipes[0], F_SETFD, FD_CLOEXEC);
fcntl(pipes[1], F_SETFD, FD_CLOEXEC);
}
}

View File

@@ -17,7 +17,7 @@ private:
{
WATCH_LEAKS(helper_t);
helper_t (int fd) : fd(fd) { if(fd != -1) fcntl(fd, F_SETFD, 1); }
helper_t (int fd) : fd(fd) { if(fd != -1) fcntl(fd, F_SETFD, FD_CLOEXEC); }
~helper_t () { if(fd != -1) close(fd); }
int fd;
};

View File

@@ -99,8 +99,8 @@ namespace network
{
close(input[0]);
close(output[1]);
fcntl(input[1], F_SETFD, 1);
fcntl(output[0], F_SETFD, 1);
fcntl(input[1], F_SETFD, FD_CLOEXEC);
fcntl(output[0], F_SETFD, FD_CLOEXEC);
}
return true;
}

View File

@@ -48,8 +48,8 @@ namespace network
}
else
{
fcntl(input = in[1], F_SETFD, 1);
fcntl(output = out[0], F_SETFD, 1);
fcntl(input = in[1], F_SETFD, FD_CLOEXEC);
fcntl(output = out[0], F_SETFD, FD_CLOEXEC);
}
}
return pid;