diff -r 383503790304 dwm.c --- a/dwm.c Sat Sep 22 23:03:45 2007 +0200 +++ b/dwm.c Sat Sep 22 23:04:19 2007 +0200 @@ -126,6 +126,7 @@ void destroynotify(XEvent *e); void destroynotify(XEvent *e); void detach(Client *c); void detachstack(Client *c); +void doreload(void); void drawbar(void); void drawsquare(Bool filled, Bool empty, unsigned long col[ColLast]); void drawtext(const char *text, unsigned long col[ColLast]); @@ -185,6 +186,7 @@ void updatebarpos(void); void updatebarpos(void); void updatesizehints(Client *c); void updatetitle(Client *c); +void sigusr1(int notused); void view(const char *arg); int xerror(Display *dpy, XErrorEvent *ee); int xerrordummy(Display *dsply, XErrorEvent *ee); @@ -192,6 +194,8 @@ void zoom(const char *arg); void zoom(const char *arg); /* variables */ +char **cargv; +char **environ; char stext[256]; double mwfact; int screen, sx, sy, sw, sh, wax, way, waw, wah; @@ -218,6 +222,7 @@ void (*handler[LASTEvent]) (XEvent *) = }; Atom wmatom[WMLast], netatom[NetLast]; Bool otherwm, readin; +Bool reload = False; Bool running = True; Bool *seltags; Bool selscreen = True; @@ -376,7 +381,6 @@ checkotherwm(void) { void cleanup(void) { - close(STDIN_FILENO); while(stack) { unban(stack); unmanage(stack); @@ -528,6 +532,11 @@ detachstack(Client *c) { for(tc=&stack; *tc && *tc != c; tc=&(*tc)->snext); *tc = c->snext; +} + +void doreload(void) { + execve(cargv[0], cargv, environ); + eprint("Can't exec: %s", strerror(errno)); } void @@ -1562,6 +1571,8 @@ setup(void) { /* multihead support */ selscreen = XQueryPointer(dpy, root, &w, &w, &d, &d, &d, &d, &mask); + if (signal(SIGUSR1, sigusr1) == SIG_ERR) + eprint("Can't bind to signal USR1"); } void @@ -1874,6 +1885,11 @@ xerror(Display *dpy, XErrorEvent *ee) { return xerrorxlib(dpy, ee); /* may call exit */ } +void sigusr1(int notused) { + quit(NULL); + reload = True; +} + int xerrordummy(Display *dsply, XErrorEvent *ee) { return 0; @@ -1920,6 +1936,7 @@ main(int argc, char *argv[]) { eprint("dwm-"VERSION", © 2006-2007 A. R. Garbe, S. van Dijk, J. Salmi, P. Hruby, S. Nagy\n"); else if(argc != 1) eprint("usage: dwm [-v]\n"); + cargv = argv; setlocale(LC_CTYPE, ""); if(!(dpy = XOpenDisplay(0))) @@ -1935,5 +1952,6 @@ main(int argc, char *argv[]) { cleanup(); XCloseDisplay(dpy); + if (reload) doreload(); return 0; }