dwm

git clone git://mattcarlson.org/repos/dwm.git
Log | Files | Refs

commit d30bf089a8d21b2984980bb29c697c4244561d9c
parent 81932973deb2037e770e979f06eaf147b6a1a854
Author: Matthew Carlson <matt@mcarlson.xyz>
Date:   Thu, 15 Jul 2021 22:37:50 -0400

Merge branch 'restartsig' into dwm

Diffstat:
Mdwm.c | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/dwm.c b/dwm.c @@ -244,6 +244,8 @@ static void seturgent(Client *c, int urg); static void showhide(Client *c); static void sigchld(int unused); static void sigstatusbar(const Arg *arg); +static void sighup(int unused); +static void sigterm(int unused); static void spawn(const Arg *arg); static void tag(const Arg *arg); static void tagmon(const Arg *arg); @@ -315,6 +317,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { [UnmapNotify] = unmapnotify }; static Atom wmatom[WMLast], netatom[NetLast]; +static int restart = 0; static int running = 1; static Cur *cursor[CurLast]; static Clr **scheme; @@ -1478,6 +1481,7 @@ propertynotify(XEvent *e) void quit(const Arg *arg) { + if(arg->i) restart = 1; running = 0; } @@ -1766,6 +1770,9 @@ setup(void) /* clean up any zombies immediately */ sigchld(0); + signal(SIGHUP, sighup); + signal(SIGTERM, sigterm); + /* init screen */ screen = DefaultScreen(dpy); sw = DisplayWidth(dpy, screen); @@ -1886,6 +1893,20 @@ sigstatusbar(const Arg *arg) } void +sighup(int unused) +{ + Arg a = {.i = 1}; + quit(&a); +} + +void +sigterm(int unused) +{ + Arg a = {.i = 0}; + quit(&a); +} + +void spawn(const Arg *arg) { if (fork() == 0) { @@ -2651,6 +2672,7 @@ main(int argc, char *argv[]) #endif /* __OpenBSD__ */ scan(); run(); + if(restart) execvp(argv[0], argv); cleanup(); XCloseDisplay(dpy); return EXIT_SUCCESS;