Merge pull request #189 from Necoro/fix_signal
Fix signal handling to avoid deadlocks
This commit is contained in:
commit
604feab0d2
@ -25,7 +25,9 @@ endif
|
|||||||
CPPFLAGS += -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${INIFLAGS}
|
CPPFLAGS += -D_BSD_SOURCE -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS} ${INIFLAGS}
|
||||||
CFLAGS += -g --std=gnu99 -pedantic -Wall -Wno-overlength-strings -Os ${STATIC} ${CPPFLAGS} ${EXTRACFLAGS}
|
CFLAGS += -g --std=gnu99 -pedantic -Wall -Wno-overlength-strings -Os ${STATIC} ${CPPFLAGS} ${EXTRACFLAGS}
|
||||||
|
|
||||||
pkg_config_packs:="dbus-1 x11 freetype2 xext xft xscrnsaver glib-2.0 gio-2.0 pango cairo pangocairo"
|
pkg_config_packs := dbus-1 x11 freetype2 xext xft xscrnsaver \
|
||||||
|
"glib-2.0 >= 2.36" gio-2.0 \
|
||||||
|
pango cairo pangocairo
|
||||||
|
|
||||||
# check if we need libxdg-basedir
|
# check if we need libxdg-basedir
|
||||||
ifeq (,$(findstring STATIC_CONFIG,$(CFLAGS)))
|
ifeq (,$(findstring STATIC_CONFIG,$(CFLAGS)))
|
||||||
|
37
dunst.c
37
dunst.c
@ -18,6 +18,7 @@
|
|||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include <glib-unix.h>
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/XKBlib.h>
|
#include <X11/XKBlib.h>
|
||||||
#include <X11/Xatom.h>
|
#include <X11/Xatom.h>
|
||||||
@ -271,6 +272,22 @@ gboolean run(void *data)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gboolean pause_signal (gpointer data)
|
||||||
|
{
|
||||||
|
pause_display = true;
|
||||||
|
wake_up();
|
||||||
|
|
||||||
|
return G_SOURCE_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean unpause_signal (gpointer data)
|
||||||
|
{
|
||||||
|
pause_display = false;
|
||||||
|
wake_up();
|
||||||
|
|
||||||
|
return G_SOURCE_CONTINUE;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -300,9 +317,6 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
x_setup();
|
x_setup();
|
||||||
|
|
||||||
signal(SIGUSR1, pause_signal_handler);
|
|
||||||
signal(SIGUSR2, pause_signal_handler);
|
|
||||||
|
|
||||||
if (settings.startup_notification) {
|
if (settings.startup_notification) {
|
||||||
notification *n = malloc(sizeof(notification));
|
notification *n = malloc(sizeof(notification));
|
||||||
n->appname = strdup("dunst");
|
n->appname = strdup("dunst");
|
||||||
@ -345,6 +359,9 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
g_source_attach(x11_source, NULL);
|
g_source_attach(x11_source, NULL);
|
||||||
|
|
||||||
|
g_unix_signal_add(SIGUSR1, pause_signal, NULL);
|
||||||
|
g_unix_signal_add(SIGUSR2, unpause_signal, NULL);
|
||||||
|
|
||||||
run(NULL);
|
run(NULL);
|
||||||
g_main_loop_run(mainloop);
|
g_main_loop_run(mainloop);
|
||||||
|
|
||||||
@ -353,20 +370,6 @@ int main(int argc, char *argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pause_signal_handler(int sig)
|
|
||||||
{
|
|
||||||
if (sig == SIGUSR1) {
|
|
||||||
pause_display = true;
|
|
||||||
wake_up();
|
|
||||||
}
|
|
||||||
if (sig == SIGUSR2) {
|
|
||||||
pause_display = false;
|
|
||||||
wake_up();
|
|
||||||
}
|
|
||||||
|
|
||||||
signal(sig, pause_signal_handler);
|
|
||||||
}
|
|
||||||
|
|
||||||
void usage(int exit_status)
|
void usage(int exit_status)
|
||||||
{
|
{
|
||||||
fputs("usage:\n", stderr);
|
fputs("usage:\n", stderr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user