TextMate is a graphical text editor for OS X 10.7+
Revisão | 9b8daf674a8edfad746212dce433eac7a8529c08 (tree) |
---|---|
Hora | 2012-08-24 03:28:54 |
Autor | Allan Odgaard <git@abet...> |
Commiter | Allan Odgaard |
Use symbolic name for FD_CLOEXEC
Unsure why I was using ‘1’ — perhaps the symbolic name was missing in the older SDK.
@@ -136,7 +136,7 @@ namespace | ||
136 | 136 | } |
137 | 137 | |
138 | 138 | socket_t fd(socket(AF_UNIX, SOCK_STREAM, 0)); |
139 | - fcntl(fd, F_SETFD, 1); | |
139 | + fcntl(fd, F_SETFD, FD_CLOEXEC); | |
140 | 140 | struct sockaddr_un addr = { 0, AF_UNIX }; |
141 | 141 | strcpy(addr.sun_path, _socket_path); |
142 | 142 | addr.sun_len = SUN_LEN(&addr); |
@@ -169,7 +169,7 @@ namespace | ||
169 | 169 | socket_t fd(socket(AF_INET, SOCK_STREAM, 0)); |
170 | 170 | setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); |
171 | 171 | |
172 | - fcntl(fd, F_SETFD, 1); | |
172 | + fcntl(fd, F_SETFD, FD_CLOEXEC); | |
173 | 173 | struct sockaddr_in iaddr = { sizeof(sockaddr_in), AF_INET, htons(_port), { htonl(_ip) } }; |
174 | 174 | if(-1 == bind(fd, (sockaddr*)&iaddr, sizeof(iaddr))) |
175 | 175 | fprintf(stderr, "bind(): %s\n", strerror(errno)); |
@@ -31,7 +31,7 @@ namespace | ||
31 | 31 | { |
32 | 32 | client_key = server().register_client(this); |
33 | 33 | int newFd = dup(fd); |
34 | - fcntl(newFd, F_SETFD, 1); | |
34 | + fcntl(newFd, F_SETFD, FD_CLOEXEC); | |
35 | 35 | server().send_request(client_key, (request_t){ newFd, str }); |
36 | 36 | } |
37 | 37 |
@@ -67,7 +67,7 @@ namespace filter | ||
67 | 67 | { |
68 | 68 | _client_key = write_server().register_client(this); |
69 | 69 | int newFd = dup(fd); |
70 | - fcntl(newFd, F_SETFD, 1); | |
70 | + fcntl(newFd, F_SETFD, FD_CLOEXEC); | |
71 | 71 | write_server().send_request(_client_key, (request_t){ newFd, bytes }); |
72 | 72 | } |
73 | 73 |
@@ -10,8 +10,8 @@ namespace io | ||
10 | 10 | write_pipe = pipes[1]; |
11 | 11 | if(close_on_exec) |
12 | 12 | { |
13 | - fcntl(pipes[0], F_SETFD, 1); | |
14 | - fcntl(pipes[1], F_SETFD, 1); | |
13 | + fcntl(pipes[0], F_SETFD, FD_CLOEXEC); | |
14 | + fcntl(pipes[1], F_SETFD, FD_CLOEXEC); | |
15 | 15 | } |
16 | 16 | } |
17 | 17 |
@@ -17,7 +17,7 @@ private: | ||
17 | 17 | { |
18 | 18 | WATCH_LEAKS(helper_t); |
19 | 19 | |
20 | - helper_t (int fd) : fd(fd) { if(fd != -1) fcntl(fd, F_SETFD, 1); } | |
20 | + helper_t (int fd) : fd(fd) { if(fd != -1) fcntl(fd, F_SETFD, FD_CLOEXEC); } | |
21 | 21 | ~helper_t () { if(fd != -1) close(fd); } |
22 | 22 | int fd; |
23 | 23 | }; |
@@ -99,8 +99,8 @@ namespace network | ||
99 | 99 | { |
100 | 100 | close(input[0]); |
101 | 101 | close(output[1]); |
102 | - fcntl(input[1], F_SETFD, 1); | |
103 | - fcntl(output[0], F_SETFD, 1); | |
102 | + fcntl(input[1], F_SETFD, FD_CLOEXEC); | |
103 | + fcntl(output[0], F_SETFD, FD_CLOEXEC); | |
104 | 104 | } |
105 | 105 | return true; |
106 | 106 | } |
@@ -48,8 +48,8 @@ namespace network | ||
48 | 48 | } |
49 | 49 | else |
50 | 50 | { |
51 | - fcntl(input = in[1], F_SETFD, 1); | |
52 | - fcntl(output = out[0], F_SETFD, 1); | |
51 | + fcntl(input = in[1], F_SETFD, FD_CLOEXEC); | |
52 | + fcntl(output = out[0], F_SETFD, FD_CLOEXEC); | |
53 | 53 | } |
54 | 54 | } |
55 | 55 | return pid; |