adb: fix adb_close() vs. unix_close() usage
Document the differences between adb_*() and unix_*() in the function
prototypes in sysdeps.h. See the file for the details (CR/LF
translation, well-known file descriptors, etc.).
Fix adb_read(), adb_write(), and adb_close() calls that should really be
unix_read(), unix_write(), and unix_close(). Note that this should have
no impact on unix because on unix, unix_read/unix_write/unix_close are
macros that map to adb_read/adb_write/adb_close.
Improve sysdeps_win32.cpp file descriptor diagnostic logging to output
the name of the function that was passed a bad file descriptor.
Change-Id: I0a1d9c28772656c80bcc303ef8b61fccf4cd637c
Signed-off-by: Spencer Low <CompareAndSwap@gmail.com>
diff --git a/services.cpp b/services.cpp
index a9edbe5..2fd75ab 100644
--- a/services.cpp
+++ b/services.cpp
@@ -252,7 +252,7 @@
*pid = forkpty(&ptm, pts_name, nullptr, nullptr);
if (*pid == -1) {
printf("- fork failed: %s -\n", strerror(errno));
- adb_close(ptm);
+ unix_close(ptm);
return -1;
}
@@ -263,7 +263,7 @@
if (pts == -1) {
fprintf(stderr, "child failed to open pseudo-term slave %s: %s\n",
pts_name, strerror(errno));
- adb_close(ptm);
+ unix_close(ptm);
exit(-1);
}
@@ -272,16 +272,16 @@
termios tattr;
if (tcgetattr(pts, &tattr) == -1) {
fprintf(stderr, "tcgetattr failed: %s\n", strerror(errno));
- adb_close(pts);
- adb_close(ptm);
+ unix_close(pts);
+ unix_close(ptm);
exit(-1);
}
cfmakeraw(&tattr);
if (tcsetattr(pts, TCSADRAIN, &tattr) == -1) {
fprintf(stderr, "tcsetattr failed: %s\n", strerror(errno));
- adb_close(pts);
- adb_close(ptm);
+ unix_close(pts);
+ unix_close(ptm);
exit(-1);
}
}
@@ -290,8 +290,8 @@
dup2(pts, STDOUT_FILENO);
dup2(pts, STDERR_FILENO);
- adb_close(pts);
- adb_close(ptm);
+ unix_close(pts);
+ unix_close(ptm);
execl(cmd, cmd, arg0, arg1, nullptr);
fprintf(stderr, "- exec '%s' failed: %s (%d) -\n",