diff options
| author | Anselm R Garbe <garbeam@gmail.com> | 2008-12-04 20:15:00 +0000 |
|---|---|---|
| committer | Anselm R Garbe <garbeam@gmail.com> | 2008-12-04 20:15:00 +0000 |
| commit | 2b047e460b5c4ddb0a72eac1bbe292539bc9049e (patch) | |
| tree | 77c48d0229d05975247c6c29503ccde29e9e776e /dwm.c | |
| parent | applied Gottox' comment fix (thanks) (diff) | |
| download | dwm-2b047e460b5c4ddb0a72eac1bbe292539bc9049e.tar.gz dwm-2b047e460b5c4ddb0a72eac1bbe292539bc9049e.zip | |
added Neale Pickett's spawn patch, thanks Neale
Diffstat (limited to 'dwm.c')
| -rw-r--r-- | dwm.c | 35 |
1 files changed, 16 insertions, 19 deletions
| @@ -182,6 +182,7 @@ static void setlayout(const Arg *arg); | |||
| 182 | static void setmfact(const Arg *arg); | 182 | static void setmfact(const Arg *arg); |
| 183 | static void setup(void); | 183 | static void setup(void); |
| 184 | static void showhide(Client *c); | 184 | static void showhide(Client *c); |
| 185 | static void sigchld(int signal); | ||
| 185 | static void spawn(const Arg *arg); | 186 | static void spawn(const Arg *arg); |
| 186 | static void tag(const Arg *arg); | 187 | static void tag(const Arg *arg); |
| 187 | static int textnw(const char *text, unsigned int len); | 188 | static int textnw(const char *text, unsigned int len); |
| @@ -1391,22 +1392,24 @@ showhide(Client *c) { | |||
| 1391 | } | 1392 | } |
| 1392 | } | 1393 | } |
| 1393 | 1394 | ||
| 1395 | |||
| 1396 | void | ||
| 1397 | sigchld(int signal) { | ||
| 1398 | while(0 < waitpid(-1, NULL, WNOHANG)); | ||
| 1399 | } | ||
| 1400 | |||
| 1394 | void | 1401 | void |
| 1395 | spawn(const Arg *arg) { | 1402 | spawn(const Arg *arg) { |
| 1396 | /* The double-fork construct avoids zombie processes and keeps the code | 1403 | signal(SIGCHLD, sigchld); |
| 1397 | * clean from stupid signal handlers. */ | ||
| 1398 | if(fork() == 0) { | 1404 | if(fork() == 0) { |
| 1399 | if(fork() == 0) { | 1405 | if(dpy) |
| 1400 | if(dpy) | 1406 | close(ConnectionNumber(dpy)); |
| 1401 | close(ConnectionNumber(dpy)); | 1407 | setsid(); |
| 1402 | setsid(); | 1408 | execvp(((char **)arg->v)[0], (char **)arg->v); |
| 1403 | execvp(((char **)arg->v)[0], (char **)arg->v); | 1409 | fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]); |
| 1404 | fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]); | 1410 | perror(" failed"); |
| 1405 | perror(" failed"); | ||
| 1406 | } | ||
| 1407 | exit(0); | 1411 | exit(0); |
| 1408 | } | 1412 | } |
| 1409 | wait(0); | ||
| 1410 | } | 1413 | } |
| 1411 | 1414 | ||
| 1412 | void | 1415 | void |
| @@ -1455,14 +1458,8 @@ tile(void) { | |||
| 1455 | h = wh; | 1458 | h = wh; |
| 1456 | 1459 | ||
| 1457 | for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { | 1460 | for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
| 1458 | if(i + 1 == n) { /* remainder */ | 1461 | resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) |
| 1459 | if(wy + wh - y < bh) | 1462 | ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints); |
| 1460 | resize(c, x, y, w - 2 * c->bw, wy + wh - y - 2 * c->bw, False); | ||
| 1461 | else | ||
| 1462 | resize(c, x, y, w - 2 * c->bw, wy + wh - y - 2 * c->bw, resizehints); | ||
| 1463 | } | ||
| 1464 | else | ||
| 1465 | resize(c, x, y, w - 2 * c->bw, h - 2 * c->bw, resizehints); | ||
| 1466 | if(h != wh) | 1463 | if(h != wh) |
| 1467 | y = c->y + HEIGHT(c); | 1464 | y = c->y + HEIGHT(c); |
| 1468 | } | 1465 | } |
