From ed8999456a6653612c618ab7f00d66fafdbe85ad Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Thu, 27 Apr 2023 10:04:55 +0200 Subject: [PATCH] Ignore SIGPIPE Prevent wayland clients that request the X11 clipboard but closing their read fd prematurely to crash labwc because of the unhandled SIGPIPE signal. It is caused by wlroots trying to write the X11 clipboard data to the closed fd of the wayland client. See https://github.com/labwc/labwc/issues/890#issuecomment-1524962995 for a reproducer involving xclip and wl-paste | head -c 1. Fixes #890 Reported-by: @FuzzyQuills --- src/server.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/server.c b/src/server.c index efc4e2f2..b0c09c44 100644 --- a/src/server.c +++ b/src/server.c @@ -226,6 +226,16 @@ server_init(struct server *server) event_loop, SIGTERM, handle_sigterm, server->wl_display); server->wl_event_loop = event_loop; + /* + * Prevent wayland clients that request the X11 clipboard but closing + * their read fd prematurely to crash labwc because of the unhandled + * SIGPIPE signal. It is caused by wlroots trying to write the X11 + * clipboard data to the closed fd of the wayland client. + * See https://github.com/labwc/labwc/issues/890#issuecomment-1524962995 + * for a reproducer involving xclip and wl-paste | head -c 1. + */ + signal(SIGPIPE, SIG_IGN); + /* * The backend is a feature which abstracts the underlying input and * output hardware. The autocreate option will choose the most suitable