use pthread_sigmask instead of sigprocmask

pthread is already in our vmem due to our dependencies so link to it
explicitly and use pthread_sigmask to avoid buggy sigprocmask in
multi-threaded applications.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-03-25 17:53:16 +02:00
parent f545d9641a
commit 9e87b853ab
3 changed files with 7 additions and 4 deletions

View File

@ -97,7 +97,8 @@ libkmscon_core_la_LIBADD = \
$(FREETYPE2_LIBS) \
$(XPROTO_LIBS) \
$(XKBCOMMON_LIBS) \
$(GLIB_LIBS)
$(GLIB_LIBS) \
-lpthread
kmscon_SOURCES = src/main.c
kmscon_LDADD = libkmscon-core.la

View File

@ -32,6 +32,7 @@
*/
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdbool.h>
#include <stdlib.h>
@ -540,7 +541,7 @@ int ev_eloop_add_signal(struct ev_eloop *loop, struct ev_signal *sig,
return ret;
}
sigprocmask(SIG_BLOCK, &mask, NULL);
pthread_sigmask(SIG_BLOCK, &mask, NULL);
sig->cb = cb;
sig->data = data;
ev_signal_ref(sig);
@ -617,7 +618,7 @@ static int signal_new(struct ev_signal_shared **out, struct ev_eloop *loop,
if (ret)
goto err_sig;
sigprocmask(SIG_BLOCK, &mask, NULL);
pthread_sigmask(SIG_BLOCK, &mask, NULL);
sig->next = loop->sig_list;
loop->sig_list = sig;

View File

@ -25,6 +25,7 @@
#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <pty.h>
#include <signal.h>
#include <stdlib.h>
@ -131,7 +132,7 @@ static int setup_child(int master, struct winsize *ws)
/* The child should not inherit our signal mask. */
sigemptyset(&sigset);
ret = sigprocmask(SIG_SETMASK, &sigset, NULL);
ret = pthread_sigmask(SIG_SETMASK, &sigset, NULL);
if (ret)
log_warn("cannot reset blocked signals: %m");