| 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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 SOL_SOCKET, | 140 SOL_SOCKET, |
| 141 SO_ERROR, | 141 SO_ERROR, |
| 142 &errno, | 142 &errno, |
| 143 reinterpret_cast<socklen_t*>(&len)); | 143 reinterpret_cast<socklen_t*>(&len)); |
| 144 os_error->SetCodeAndMessage(OSError::kSystem, errno); | 144 os_error->SetCodeAndMessage(OSError::kSystem, errno); |
| 145 } | 145 } |
| 146 | 146 |
| 147 | 147 |
| 148 int Socket::GetType(intptr_t fd) { | 148 int Socket::GetType(intptr_t fd) { |
| 149 struct stat buf; | 149 struct stat buf; |
| 150 if (isatty(fd)) return File::kTerminal; | |
| 151 int result = fstat(fd, &buf); | 150 int result = fstat(fd, &buf); |
| 152 if (result == -1) return -1; | 151 if (result == -1) return -1; |
| 152 if (S_ISCHR(buf.st_mode)) return File::kTerminal; |
| 153 if (S_ISFIFO(buf.st_mode)) return File::kPipe; | 153 if (S_ISFIFO(buf.st_mode)) return File::kPipe; |
| 154 if (S_ISREG(buf.st_mode)) return File::kFile; | 154 if (S_ISREG(buf.st_mode)) return File::kFile; |
| 155 return File::kOther; | 155 return File::kOther; |
| 156 } | 156 } |
| 157 | 157 |
| 158 | 158 |
| 159 intptr_t Socket::GetStdioHandle(int num) { | 159 intptr_t Socket::GetStdioHandle(int num) { |
| 160 return static_cast<intptr_t>(num); | 160 return static_cast<intptr_t>(num); |
| 161 } | 161 } |
| 162 | 162 |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 bool Socket::SetNoDelay(intptr_t fd, bool enabled) { | 291 bool Socket::SetNoDelay(intptr_t fd, bool enabled) { |
| 292 int on = enabled ? 1 : 0; | 292 int on = enabled ? 1 : 0; |
| 293 return TEMP_FAILURE_RETRY(setsockopt(fd, | 293 return TEMP_FAILURE_RETRY(setsockopt(fd, |
| 294 SOL_TCP, | 294 SOL_TCP, |
| 295 TCP_NODELAY, | 295 TCP_NODELAY, |
| 296 reinterpret_cast<char *>(&on), | 296 reinterpret_cast<char *>(&on), |
| 297 sizeof(on))) == 0; | 297 sizeof(on))) == 0; |
| 298 } | 298 } |
| 299 | 299 |
| 300 #endif // defined(TARGET_OS_LINUX) | 300 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |