summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohan Klokkhammer Helsing <johan.helsing@qt.io>2016-12-22 14:30:57 +0100
committerJohan Helsing <johan.helsing@qt.io>2017-01-03 11:07:02 +0000
commit330d786bf6a16fd6019f307f8b43de670a10f1d3 (patch)
tree989c4119285e11015d2e38851e61abd4c0578ede
parent2240e6c4c1d69189e1369aaf1999a86d13513537 (diff)
Client: Don't crash when the receiver of a paste closes the pipe
Ignore the SIGPIPE signal Task-number: QTBUG-57202 Change-Id: If22381f446675836aeb741a8e6da5473b0a27301 Reviewed-by: Martin Gräßlin <mgraesslin@kde.org> Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
-rw-r--r--src/client/qwaylanddatasource.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/client/qwaylanddatasource.cpp b/src/client/qwaylanddatasource.cpp
index 036bd0d86..c61de181b 100644
--- a/src/client/qwaylanddatasource.cpp
+++ b/src/client/qwaylanddatasource.cpp
@@ -48,6 +48,7 @@
#include <QtCore/QDebug>
#include <unistd.h>
+#include <signal.h>
#if QT_CONFIG(draganddrop)
@@ -85,7 +86,16 @@ void QWaylandDataSource::data_source_send(const QString &mime_type, int32_t fd)
{
QByteArray content = QWaylandMimeHelper::getByteArray(m_mime_data, mime_type);
if (!content.isEmpty()) {
+ // Create a sigpipe handler that does nothing, or clients may be forced to terminate
+ // if the pipe is closed in the other end.
+ struct sigaction action, oldAction;
+ action.sa_handler = SIG_IGN;
+ sigemptyset (&action.sa_mask);
+ action.sa_flags = 0;
+
+ sigaction(SIGPIPE, &action, &oldAction);
write(fd, content.constData(), content.size());
+ sigaction(SIGPIPE, &oldAction, nullptr);
}
close(fd);
}