OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
7 | 7 |
8 #include <errno.h> // NOLINT | 8 #include <errno.h> // NOLINT |
9 #include <stdio.h> // NOLINT | 9 #include <stdio.h> // NOLINT |
10 #include <stdlib.h> // NOLINT | 10 #include <stdlib.h> // NOLINT |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 SOL_SOCKET, | 136 SOL_SOCKET, |
137 SO_ERROR, | 137 SO_ERROR, |
138 &errno, | 138 &errno, |
139 reinterpret_cast<socklen_t*>(&len)); | 139 reinterpret_cast<socklen_t*>(&len)); |
140 os_error->SetCodeAndMessage(OSError::kSystem, errno); | 140 os_error->SetCodeAndMessage(OSError::kSystem, errno); |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 int Socket::GetType(intptr_t fd) { | 144 int Socket::GetType(intptr_t fd) { |
145 struct stat buf; | 145 struct stat buf; |
146 if (isatty(fd)) return File::kTerminal; | |
147 int result = fstat(fd, &buf); | 146 int result = fstat(fd, &buf); |
148 if (result == -1) return -1; | 147 if (result == -1) return -1; |
| 148 if (S_ISCHR(buf.st_mode)) return File::kTerminal; |
149 if (S_ISFIFO(buf.st_mode)) return File::kPipe; | 149 if (S_ISFIFO(buf.st_mode)) return File::kPipe; |
150 if (S_ISREG(buf.st_mode)) return File::kFile; | 150 if (S_ISREG(buf.st_mode)) return File::kFile; |
151 return File::kOther; | 151 return File::kOther; |
152 } | 152 } |
153 | 153 |
154 | 154 |
155 intptr_t Socket::GetStdioHandle(int num) { | 155 intptr_t Socket::GetStdioHandle(int num) { |
156 return static_cast<intptr_t>(num); | 156 return static_cast<intptr_t>(num); |
157 } | 157 } |
158 | 158 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 bool Socket::SetNoDelay(intptr_t fd, bool enabled) { | 277 bool Socket::SetNoDelay(intptr_t fd, bool enabled) { |
278 int on = enabled ? 1 : 0; | 278 int on = enabled ? 1 : 0; |
279 return TEMP_FAILURE_RETRY(setsockopt(fd, | 279 return TEMP_FAILURE_RETRY(setsockopt(fd, |
280 IPPROTO_TCP, | 280 IPPROTO_TCP, |
281 TCP_NODELAY, | 281 TCP_NODELAY, |
282 reinterpret_cast<char *>(&on), | 282 reinterpret_cast<char *>(&on), |
283 sizeof(on))) == 0; | 283 sizeof(on))) == 0; |
284 } | 284 } |
285 | 285 |
286 #endif // defined(TARGET_OS_MACOS) | 286 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |