From fbd175c0c95ba1629d50970b8e5e814ed9f7f42a Mon Sep 17 00:00:00 2001 From: Matthias Grob Date: Tue, 18 Sep 2018 14:58:45 +0200 Subject: [PATCH] posix-shell server: switch pipe flag to read/write to make it non-blocking and ommit opening the same named pipe multiple times inside the same process which seems to be not supported in cygwin. --- platforms/posix/src/px4_daemon/server.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/platforms/posix/src/px4_daemon/server.cpp b/platforms/posix/src/px4_daemon/server.cpp index 8963bebc7a..83fd4a0cae 100644 --- a/platforms/posix/src/px4_daemon/server.cpp +++ b/platforms/posix/src/px4_daemon/server.cpp @@ -50,7 +50,13 @@ #include "pxh.h" #include "server.h" - +// In Cygwin opening and closing the same named pipe multiple times within one process doesn't work POSIX compliant. +// As a workaround we open the client send pipe file in read write mode such that we can keep it open all the time. +#if !defined(__PX4_CYGWIN) +#define CLIENT_SEND_PIPE_OFLAGS O_RDONLY +#else +#define CLIENT_SEND_PIPE_OFLAGS O_RDWR +#endif namespace px4_daemon { @@ -121,7 +127,7 @@ Server::_server_main(void *arg) } std::string client_send_pipe_path = get_client_send_pipe_path(_instance_id); - int client_send_pipe_fd = open(client_send_pipe_path.c_str(), O_RDONLY); + int client_send_pipe_fd = open(client_send_pipe_path.c_str(), CLIENT_SEND_PIPE_OFLAGS); while (true) {