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>
This commit is contained in:
parent
81f80fa19f
commit
a37ac71c33
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user