added Neale Pickett's spawn patch, thanks Neale 2b047e46
Anselm R Garbe · 2008-12-04 20:15 1 file(s) · +16 −19
dwm.c +16 −19
182 182
static void setmfact(const Arg *arg);
183 183
static void setup(void);
184 184
static void showhide(Client *c);
185 +
static void sigchld(int signal);
185 186
static void spawn(const Arg *arg);
186 187
static void tag(const Arg *arg);
187 188
static int textnw(const char *text, unsigned int len);
1391 1392
	}
1392 1393
}
1393 1394
1395 +
1396 +
void
1397 +
sigchld(int signal) {
1398 +
	while(0 < waitpid(-1, NULL, WNOHANG));
1399 +
}
1400 +
1394 1401
void
1395 1402
spawn(const Arg *arg) {
1396 -
	/* The double-fork construct avoids zombie processes and keeps the code
1397 -
	 * clean from stupid signal handlers. */
1403 +
	signal(SIGCHLD, sigchld);
1398 1404
	if(fork() == 0) {
1399 -
		if(fork() == 0) {
1400 -
			if(dpy)
1401 -
				close(ConnectionNumber(dpy));
1402 -
			setsid();
1403 -
			execvp(((char **)arg->v)[0], (char **)arg->v);
1404 -
			fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
1405 -
			perror(" failed");
1406 -
		}
1405 +
		if(dpy)
1406 +
			close(ConnectionNumber(dpy));
1407 +
		setsid();
1408 +
		execvp(((char **)arg->v)[0], (char **)arg->v);
1409 +
		fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
1410 +
		perror(" failed");
1407 1411
		exit(0);
1408 1412
	}
1409 -
	wait(0);
1410 1413
}
1411 1414
1412 1415
void
1455 1458
		h = wh;
1456 1459
1457 1460
	for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
1458 -
		if(i + 1 == n) { /* remainder */
1459 -
			if(wy + wh - y < bh)
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);
1461 +
		resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n)
1462 +
		       ? wy + wh - y - 2 * c->bw : h - 2 * c->bw), resizehints);
1466 1463
		if(h != wh)
1467 1464
			y = c->y + HEIGHT(c);
1468 1465
	}