xwayland: Avoid printing "FATAL ERROR" log messages

Since we want kwin to survive Xwayland crashes, printing "FATAL ERROR"
is highly undesirable.
This commit is contained in:
Vlad Zahorodnii 2020-09-08 11:27:42 +03:00
parent b13a74c908
commit 8697bcd7e9

View file

@ -37,13 +37,15 @@
#endif #endif
#include <sys/socket.h> #include <sys/socket.h>
#include <cerrno>
#include <cstring>
#include <iostream> #include <iostream>
static void readDisplay(int pipe) static void readDisplay(int pipe)
{ {
QFile readPipe; QFile readPipe;
if (!readPipe.open(pipe, QIODevice::ReadOnly)) { if (!readPipe.open(pipe, QIODevice::ReadOnly)) {
std::cerr << "FATAL ERROR failed to open pipe to start X Server" << std::endl; qCWarning(KWIN_XWL) << "Failed to open X11 display name pipe:" << readPipe.errorString();
exit(1); exit(1);
} }
QByteArray displayNumber = readPipe.readLine(); QByteArray displayNumber = readPipe.readLine();
@ -90,32 +92,32 @@ void Xwayland::start()
int pipeFds[2]; int pipeFds[2];
if (pipe(pipeFds) != 0) { if (pipe(pipeFds) != 0) {
std::cerr << "FATAL ERROR failed to create pipe to start Xwayland " << std::endl; qCWarning(KWIN_XWL, "Failed to create pipe to start Xwayland: %s", strerror(errno));
emit errorOccurred(); emit errorOccurred();
return; return;
} }
int sx[2]; int sx[2];
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) { if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, sx) < 0) {
std::cerr << "FATAL ERROR: failed to open socket to open XCB connection" << std::endl; qCWarning(KWIN_XWL, "Failed to open socket for XCB connection: %s", strerror(errno));
emit errorOccurred(); emit errorOccurred();
return; return;
} }
int fd = dup(sx[1]); int fd = dup(sx[1]);
if (fd < 0) { if (fd < 0) {
std::cerr << "FATAL ERROR: failed to open socket to open XCB connection" << std::endl; qCWarning(KWIN_XWL, "Failed to open socket for XCB connection: %s", strerror(errno));
emit errorOccurred(); emit errorOccurred();
return; return;
} }
const int waylandSocket = waylandServer()->createXWaylandConnection(); const int waylandSocket = waylandServer()->createXWaylandConnection();
if (waylandSocket == -1) { if (waylandSocket == -1) {
std::cerr << "FATAL ERROR: failed to open socket for Xwayland" << std::endl; qCWarning(KWIN_XWL, "Failed to open socket for Xwayland server: %s", strerror(errno));
emit errorOccurred(); emit errorOccurred();
return; return;
} }
const int wlfd = dup(waylandSocket); const int wlfd = dup(waylandSocket);
if (wlfd < 0) { if (wlfd < 0) {
std::cerr << "FATAL ERROR: failed to open socket for Xwayland" << std::endl; qCWarning(KWIN_XWL, "Failed to open socket for Xwayland server: %s", strerror(errno));
emit errorOccurred(); emit errorOccurred();
return; return;
} }