adb: SIGWINCH support for Windows
- Introduces unix_read_interruptible() which is like unix_read() except
that it can return EINTR.
- The big idea is that the Windows ReadConsoleInput() API will return an
event on window resize and then we return EINTR from
unix_read_interruptible() just like Unix.
- Only handles horizontal resize since Windows doesn't seem to give an
event for vertical resize when no special screen buffer is used. This
should be sufficient for the primary use case of adb on Windows
(people are not running vi in the first place).
Change-Id: Id8d1710b559834c8098f2d7fbecedf2d0ade4b88
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
diff --git a/adb/sysdeps.h b/adb/sysdeps.h
index 2190c61..0abade4 100644
--- a/adb/sysdeps.h
+++ b/adb/sysdeps.h
@@ -164,8 +164,13 @@
#undef close
#define close ____xxx_close
+// Like unix_read(), but may return EINTR.
+extern int unix_read_interruptible(int fd, void* buf, size_t len);
+
// See the comments for the !defined(_WIN32) version of unix_read().
-extern int unix_read(int fd, void* buf, size_t len);
+static __inline__ int unix_read(int fd, void* buf, size_t len) {
+ return TEMP_FAILURE_RETRY(unix_read_interruptible(fd, buf, len));
+}
#undef read
#define read ___xxx_read
@@ -517,6 +522,11 @@
return TEMP_FAILURE_RETRY( read( fd, buf, len ) );
}
+// Like unix_read(), but does not handle EINTR.
+static __inline__ int unix_read_interruptible(int fd, void* buf, size_t len) {
+ return read(fd, buf, len);
+}
+
#undef read
#define read ___xxx_read