Avoid SIGPIPE in adb.

We're now able to send packets faster than the device can handle them,
meaning that sometimes we're several packets through before the device
says "hey, wait, I can't write" and closes the connection. At best this
led to us reporting that we couldn't sync because "Connection reset";
at worst we'd get SIGPIPE because we were still streaming to a connection
that had already been closed.

This change renames adb_main adb_server_main, and moves the ignoring of
SIGPIPE into adb_commandline so it applies to both client and server (but
not adbd).

This change doesn't address the "wrong error message" part of the problem,
but at least it means you'll get *an* error message.

Bug: http://b/25230872
Change-Id: Ic60e4d13ed03fdcdf0d5cbc97201ebd1097c16ed
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index 73c8912..bd3813e 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -1296,6 +1296,11 @@
     TransportType transport_type = kTransportAny;
     int ack_reply_fd = -1;
 
+#if !defined(_WIN32)
+    // We'd rather have EPIPE than SIGPIPE.
+    signal(SIGPIPE, SIG_IGN);
+#endif
+
     // If defined, this should be an absolute path to
     // the directory containing all of the various system images
     // for a particular product.  If not defined, and the adb
@@ -1427,7 +1432,7 @@
                 fprintf(stderr, "reply fd for adb server to client communication not specified.\n");
                 return usage();
             }
-            r = adb_main(is_daemon, server_port, ack_reply_fd);
+            r = adb_server_main(is_daemon, server_port, ack_reply_fd);
         } else {
             r = launch_server(server_port);
         }