From c882ca93892ea9759b0da58454a6da8af21bdb05 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Wed, 14 Nov 2018 17:04:17 +0100 Subject: [PATCH] On Posix: Don't shutdown (half) the connection from the client. This triggered POLLHUP too early on Mac. --- platforms/posix/src/px4_daemon/client.cpp | 6 ------ platforms/posix/src/px4_daemon/server.cpp | 5 +++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/platforms/posix/src/px4_daemon/client.cpp b/platforms/posix/src/px4_daemon/client.cpp index 194875aabe..f6604b9566 100644 --- a/platforms/posix/src/px4_daemon/client.cpp +++ b/platforms/posix/src/px4_daemon/client.cpp @@ -124,12 +124,6 @@ Client::_send_cmds(const int argc, const char **argv) buf += n_sent; } - // Let the server know we're done writing. - if (shutdown(_fd, SHUT_WR) < 0) { - PX4_ERR("shutdown() failed: %s", strerror(errno)); - return -1; - } - return 0; } diff --git a/platforms/posix/src/px4_daemon/server.cpp b/platforms/posix/src/px4_daemon/server.cpp index f9f5b56854..d327385507 100644 --- a/platforms/posix/src/px4_daemon/server.cpp +++ b/platforms/posix/src/px4_daemon/server.cpp @@ -220,14 +220,15 @@ void cmd.resize(n + 1024); ssize_t n_read = read(fd, &cmd[n], cmd.size() - n); - if (n_read < 0) { + if (n_read <= 0) { _cleanup(fd); return nullptr; } cmd.resize(n + n_read); - if (n_read == 0) { + // Command ends in 0x00 (no tty) or 0x01 (tty). + if (!cmd.empty() && cmd.back() < 2) { break; } }