dwm.c
changeset 1365 b34298951f7b
parent 1363 4004d6116035
child 1366 335301ed102f
equal deleted inserted replaced
1364:a93d5d1a3389 1365:b34298951f7b
   180 static void setclientstate(Client *c, long state);
   180 static void setclientstate(Client *c, long state);
   181 static void setlayout(const Arg *arg);
   181 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);
       
   186 static void spawn(const Arg *arg);
   185 static void spawn(const Arg *arg);
   187 static void tag(const Arg *arg);
   186 static void tag(const Arg *arg);
   188 static int textnw(const char *text, unsigned int len);
   187 static int textnw(const char *text, unsigned int len);
   189 static void tile(void);
   188 static void tile(void);
   190 static void togglebar(const Arg *arg);
   189 static void togglebar(const Arg *arg);
  1390 		showhide(c->snext);
  1389 		showhide(c->snext);
  1391 		XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
  1390 		XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
  1392 	}
  1391 	}
  1393 }
  1392 }
  1394 
  1393 
  1395 
       
  1396 void
       
  1397 sigchld(int signal) {
       
  1398 	while(0 < waitpid(-1, NULL, WNOHANG));
       
  1399 }
       
  1400 
       
  1401 void
  1394 void
  1402 spawn(const Arg *arg) {
  1395 spawn(const Arg *arg) {
  1403 	signal(SIGCHLD, sigchld);
  1396 	/* The double-fork construct avoids zombie processes and keeps the code
       
  1397 	 * clean from stupid signal handlers. */
  1404 	if(fork() == 0) {
  1398 	if(fork() == 0) {
  1405 		if(dpy)
  1399 		if(fork() == 0) {
  1406 			close(ConnectionNumber(dpy));
  1400 			if(dpy)
  1407 		setsid();
  1401 				close(ConnectionNumber(dpy));
  1408 		execvp(((char **)arg->v)[0], (char **)arg->v);
  1402 			setsid();
  1409 		fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
  1403 			execvp(((char **)arg->v)[0], (char **)arg->v);
  1410 		perror(" failed");
  1404 			fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
       
  1405 			perror(" failed");
       
  1406 		}
  1411 		exit(0);
  1407 		exit(0);
  1412 	}
  1408 	}
       
  1409 	wait(0);
  1413 }
  1410 }
  1414 
  1411 
  1415 void
  1412 void
  1416 tag(const Arg *arg) {
  1413 tag(const Arg *arg) {
  1417 	if(sel && arg->ui & TAGMASK) {
  1414 	if(sel && arg->ui & TAGMASK) {