Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8c5511c6 authored by Elliott Hughes's avatar Elliott Hughes Committed by Gerrit Code Review
Browse files

Merge "Avoid SIGPIPE in adb."

parents b0df9dca 65433da1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ void handle_packet(apacket *p, atransport *t);

void get_my_path(char *s, size_t maxLen);
int launch_server(int server_port);
int adb_main(int is_daemon, int server_port, int ack_reply_fd);
int adb_server_main(int is_daemon, int server_port, int ack_reply_fd);

/* initialize a transport object's func pointers and state */
#if ADB_HOST
+3 −6
Original line number Diff line number Diff line
@@ -86,8 +86,7 @@ static void close_stdin() {

static void setup_daemon_logging(void) {
    const std::string log_file_path(GetLogFilePath());
    int fd = unix_open(log_file_path.c_str(), O_WRONLY | O_CREAT | O_APPEND,
                       0640);
    int fd = unix_open(log_file_path.c_str(), O_WRONLY | O_CREAT | O_APPEND, 0640);
    if (fd == -1) {
        fatal("cannot open '%s': %s", log_file_path.c_str(), strerror(errno));
    }
@@ -103,10 +102,10 @@ static void setup_daemon_logging(void) {
    LOG(INFO) << adb_version();
}

int adb_main(int is_daemon, int server_port, int ack_reply_fd) {
int adb_server_main(int is_daemon, int server_port, int ack_reply_fd) {
#if defined(_WIN32)
    // adb start-server starts us up with stdout and stderr hooked up to
    // anonymous pipes to. When the C Runtime sees this, it makes stderr and
    // anonymous pipes. When the C Runtime sees this, it makes stderr and
    // stdout buffered, but to improve the chance that error output is seen,
    // unbuffer stdout and stderr just like if we were run at the console.
    // This also keeps stderr unbuffered when it is redirected to adb.log.
@@ -120,8 +119,6 @@ int adb_main(int is_daemon, int server_port, int ack_reply_fd) {
    }

    SetConsoleCtrlHandler(ctrlc_handler, TRUE);
#else
    signal(SIGPIPE, SIG_IGN);
#endif

    init_transport_registration();
+6 −1
Original line number Diff line number Diff line
@@ -1296,6 +1296,11 @@ int adb_commandline(int argc, const char **argv) {
    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 @@ int adb_commandline(int argc, const char **argv) {
                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);
        }