From fb6d117c42ce3d9988ff44c079814b3840b1e37f Mon Sep 17 00:00:00 2001 From: Axel Wagner Date: Thu, 30 Dec 2010 21:09:32 +0100 Subject: [PATCH] Port sighandler to tree-branch --- Makefile | 2 +- include/all.h | 1 + src/main.c | 6 ++++++ src/sighandler.c | 12 +++++------- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 4f2ab77f..89647f6c 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ include $(TOPDIR)/common.mk # Depend on the object files of all source-files in src/*.c and on all header files AUTOGENERATED:=src/cfgparse.tab.c src/cfgparse.yy.c src/cmdparse.tab.c src/cmdparse.yy.c -FILES:=src/ipc.c src/main.c src/log.c src/util.c src/tree.c src/xcb.c src/manage.c src/workspace.c src/x.c src/floating.c src/click.c src/config.c src/handlers.c src/randr.c src/xinerama.c src/con.c src/load_layout.c src/render.c src/window.c src/match.c src/xcursor.c src/resize.c +FILES:=src/ipc.c src/main.c src/log.c src/util.c src/tree.c src/xcb.c src/manage.c src/workspace.c src/x.c src/floating.c src/click.c src/config.c src/handlers.c src/randr.c src/xinerama.c src/con.c src/load_layout.c src/render.c src/window.c src/match.c src/xcursor.c src/resize.c src/sighandler.c FILES:=$(FILES:.c=.o) HEADERS:=$(filter-out include/loglevels.h,$(wildcard include/*.h)) diff --git a/include/all.h b/include/all.h index 23943b29..3cc28940 100644 --- a/include/all.h +++ b/include/all.h @@ -53,5 +53,6 @@ #include "cmdparse.h" #include "xcursor.h" #include "resize.h" +#include "sighandler.h" #endif diff --git a/src/main.c b/src/main.c index b6923d6a..e30887c9 100644 --- a/src/main.c +++ b/src/main.c @@ -385,6 +385,12 @@ int main(int argc, char *argv[]) { manage_existing_windows(root); + setup_signal_handler(); + + /* Ignore SIGPIPE to survive errors when an IPC client disconnects + * while we are sending him a message */ + signal(SIGPIPE, SIG_IGN); + /* Autostarting exec-lines */ if (autostart) { struct Autostart *exec; diff --git a/src/sighandler.c b/src/sighandler.c index 92cbc5cb..26ed1a68 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -50,17 +50,17 @@ static int crash_text_longest = 1; * Draw the window containing the info text * */ -static int sig_draw_window(xcb_connection_t *conn, xcb_window_t win, int width, int height, int font_height) { +static int sig_draw_window(xcb_window_t win, int width, int height, int font_height) { /* re-draw the background */ xcb_rectangle_t border = { 0, 0, width, height}, inner = { 2, 2, width - 4, height - 4}; - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#FF0000")); + xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#FF0000")); xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &border); - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#000000")); + xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#000000")); xcb_poly_fill_rectangle(conn, pixmap, pixmap_gc, 1, &inner); /* restore font color */ - xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel(conn, "#FFFFFF")); + xcb_change_gc_single(conn, pixmap_gc, XCB_GC_FOREGROUND, get_colorpixel("#FFFFFF")); for (int i = 0; i < sizeof(crash_text) / sizeof(char*); i++) { int text_len = strlen(crash_text[i]); @@ -156,8 +156,6 @@ void handle_signal(int sig, siginfo_t *info, void *data) { sigaction(sig, &action, NULL); raised_signal = sig; - xcb_connection_t *conn = global_conn; - /* setup event handler for key presses */ xcb_event_handlers_t sig_evenths; memset(&sig_evenths, 0, sizeof(xcb_event_handlers_t)); @@ -200,7 +198,7 @@ void handle_signal(int sig, siginfo_t *info, void *data) { xcb_grab_pointer(conn, false, win, XCB_NONE, XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, win, XCB_NONE, XCB_CURRENT_TIME); - sig_draw_window(conn, win, width, height, font->height); + sig_draw_window(win, width, height, font->height); xcb_flush(conn); }