Skip to content

Commit

Permalink
use pthread_sigmask instead of sigprocmask
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
David Herrmann committed Mar 25, 2012
1 parent f545d96 commit 9e87b85
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion Makefile.am
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/eloop.c
Expand Up @@ -32,6 +32,7 @@
*/

#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdbool.h>
#include <stdlib.h>
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion src/pty.c
Expand Up @@ -25,6 +25,7 @@

#include <errno.h>
#include <fcntl.h>
#include <pthread.h>
#include <pty.h>
#include <signal.h>
#include <stdlib.h>
Expand Down Expand Up @@ -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");

Expand Down

0 comments on commit 9e87b85

Please sign in to comment.