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

Unified Diff: base/platform_file_posix.cc

Issue 10392181: Implement serial API for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix weird Windows build error. Created 8 years, 7 months 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 side-by-side diff with in-line comments
Download patch
Index: base/platform_file_posix.cc
diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc
index 9b42c7a184fea0d22ee060e1e3022c87325686c3..ec0202628e5928d92cda33ff809d75b9e9ce4cb7 100644
--- a/base/platform_file_posix.cc
+++ b/base/platform_file_posix.cc
@@ -78,6 +78,10 @@ PlatformFile CreatePlatformFile(const FilePath& name, int flags,
NOTREACHED();
}
+ if (flags & PLATFORM_FILE_TERMINAL_DEVICE) {
+ open_flags |= O_NOCTTY | O_NDELAY;
+ }
+
COMPILE_ASSERT(O_RDONLY == 0, O_RDONLY_must_equal_zero);
int mode = S_IRUSR | S_IWUSR;
@@ -166,6 +170,10 @@ int ReadPlatformFile(PlatformFile file, int64 offset, char* data, int size) {
do {
rv = HANDLE_EINTR(pread(file, data + bytes_read,
size - bytes_read, offset + bytes_read));
+ if (rv <= 0 && errno == ESPIPE) {
+ // The file descriptor represents a tty device. Try again without lseek.
+ rv = HANDLE_EINTR(read(file, data, size));
+ }
if (rv <= 0)
break;
@@ -195,6 +203,10 @@ int WritePlatformFile(PlatformFile file, int64 offset,
do {
rv = HANDLE_EINTR(pwrite(file, data + bytes_written,
size - bytes_written, offset + bytes_written));
+ if (rv <= 0 && errno == ESPIPE) {
+ // The file descriptor represents a tty device. Try again without lseek.
+ rv = HANDLE_EINTR(write(file, data, size));
+ }
if (rv <= 0)
break;

Powered by Google App Engine
This is Rietveld 408576698