summaryrefslogtreecommitdiffstats
path: root/src/client/qwaylanddatasource.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/qwaylanddatasource.cpp')
-rw-r--r--src/client/qwaylanddatasource.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/client/qwaylanddatasource.cpp b/src/client/qwaylanddatasource.cpp
index 9b17cdfab..c2bc9dc45 100644
--- a/src/client/qwaylanddatasource.cpp
+++ b/src/client/qwaylanddatasource.cpp
@@ -49,6 +49,7 @@
#include <unistd.h>
#include <signal.h>
+#include <fcntl.h>
QT_BEGIN_NAMESPACE
@@ -93,7 +94,15 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
action.sa_flags = 0;
sigaction(SIGPIPE, &action, &oldAction);
- write(fd, content.constData(), content.size());
+ // Some compositors (e.g., mutter) make fd with O_NONBLOCK.
+ // Since wl_data_source.send describes that fd is closed here,
+ // it should be done in a loop and don't have any advantage.
+ // Blocking operation will be used.
+ // According to fcntl(2), FSETFL ignores O_WRONLY. So this
+ // call will just remove O_NONBLOCK.
+ fcntl(fd, F_SETFL, O_WRONLY);
+ ssize_t unused = write(fd, content.constData(), content.size());
+ Q_UNUSED(unused);
sigaction(SIGPIPE, &oldAction, nullptr);
}
close(fd);