Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: runtime/bin/fdutils_linux.cc

Issue 11416006: Added FD_CLOEXEC flag to client/server socket file descriptors (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/bin/fdutils_android.cc ('k') | runtime/bin/fdutils_macos.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include <errno.h> 5 #include <errno.h>
6 #include <fcntl.h> 6 #include <fcntl.h>
7 #include <unistd.h> 7 #include <unistd.h>
8 #include <sys/ioctl.h> 8 #include <sys/ioctl.h>
9 9
10 #include "bin/fdutils.h" 10 #include "bin/fdutils.h"
11 11
12 12
13 bool FDUtils::SetCloseOnExec(intptr_t fd) {
14 intptr_t status;
15 status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFD));
16 if (status < 0) {
17 perror("fcntl F_GETFD failed");
18 return false;
19 }
20 status |= FD_CLOEXEC;
21 if (TEMP_FAILURE_RETRY(fcntl(fd, F_SETFD, status)) < 0) {
22 perror("fcntl F_SETFD failed");
23 return false;
24 }
25 return true;
26 }
27
28
13 static bool SetBlockingHelper(intptr_t fd, bool blocking) { 29 static bool SetBlockingHelper(intptr_t fd, bool blocking) {
14 intptr_t status; 30 intptr_t status;
15 status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL)); 31 status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL));
16 if (status < 0) { 32 if (status < 0) {
17 perror("fcntl F_GETFL failed"); 33 perror("fcntl F_GETFL failed");
18 return false; 34 return false;
19 } 35 }
20 status = blocking ? (status & ~O_NONBLOCK) : (status | O_NONBLOCK); 36 status = blocking ? (status & ~O_NONBLOCK) : (status | O_NONBLOCK);
21 if (TEMP_FAILURE_RETRY(fcntl(fd, F_SETFL, status)) < 0) { 37 if (TEMP_FAILURE_RETRY(fcntl(fd, F_SETFL, status)) < 0) {
22 perror("fcntl F_SETFL failed"); 38 perror("fcntl F_SETFL failed");
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 ASSERT(errno != EWOULDBLOCK); 125 ASSERT(errno != EWOULDBLOCK);
110 return -1; 126 return -1;
111 } else { 127 } else {
112 ASSERT(bytes_written > 0); 128 ASSERT(bytes_written > 0);
113 remaining -= bytes_written; 129 remaining -= bytes_written;
114 buffer_pos += bytes_written; 130 buffer_pos += bytes_written;
115 } 131 }
116 } 132 }
117 return count; 133 return count;
118 } 134 }
OLDNEW
« no previous file with comments | « runtime/bin/fdutils_android.cc ('k') | runtime/bin/fdutils_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698