From ecdb4d7e0835f2accfdb7d565fe69d9ab5e53a51 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 3 Sep 2019 11:33:27 -0700 Subject: [PATCH] Call pthread_sigmask() as early as possible so Xwayland SIGUSR1 is not caught by threads spawned by shared libraries (like the libMali.so OpenGL driver). --- sway/main.c | 13 +++++++++++++ sway/meson.build | 3 ++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/sway/main.c b/sway/main.c index 0477bbc3f..ff6c1ef2c 100644 --- a/sway/main.c +++ b/sway/main.c @@ -214,6 +214,19 @@ void enable_debug_flag(const char *flag) { } int main(int argc, char **argv) { + + // Shared libraries (such as libMali.so, the Mali OpenGL + // driver) may create their own threads. To ensure that + // Xwayland's SIGUSR1 does not hit those threads and kill + // sway, we must call pthread_sigmask() as early as possible. + // See also weston commit + // f59dc1112be50467b7c0f8aeba68f3aa10d36725 which does the + // same thing. + sigset_t mask; + sigemptyset(&mask); + sigaddset(&mask, SIGUSR1); + pthread_sigmask(SIG_BLOCK, &mask, NULL); + static int verbose = 0, debug = 0, validate = 0, allow_unsupported_gpu = 0; static struct option long_options[] = { diff --git a/sway/meson.build b/sway/meson.build index 0f943a1f3..f6ea08953 100644 --- a/sway/meson.build +++ b/sway/meson.build @@ -210,5 +210,6 @@ executable( include_directories: [sway_inc], dependencies: sway_deps, link_with: [lib_sway_common], - install: true + install: true, + link_args : '-lpthread' )