dwm.c
changeset 1371 fcdbbc9c39de
parent 1370 6d6ed7a9183c
child 1372 a02489708a2b
equal deleted inserted replaced
1370:6d6ed7a9183c 1371:fcdbbc9c39de
   176 static void setclientstate(Client *c, long state);
   176 static void setclientstate(Client *c, long state);
   177 static void setlayout(const Arg *arg);
   177 static void setlayout(const Arg *arg);
   178 static void setmfact(const Arg *arg);
   178 static void setmfact(const Arg *arg);
   179 static void setup(void);
   179 static void setup(void);
   180 static void showhide(Client *c);
   180 static void showhide(Client *c);
       
   181 static void sigchld(int signal);
   181 static void spawn(const Arg *arg);
   182 static void spawn(const Arg *arg);
   182 static void tag(const Arg *arg);
   183 static void tag(const Arg *arg);
   183 static int textnw(const char *text, unsigned int len);
   184 static int textnw(const char *text, unsigned int len);
   184 static void tile(void);
   185 static void tile(void);
   185 static void togglebar(const Arg *arg);
   186 static void togglebar(const Arg *arg);
  1338 		showhide(c->snext);
  1339 		showhide(c->snext);
  1339 		XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
  1340 		XMoveWindow(dpy, c->win, c->x + 2 * sw, c->y);
  1340 	}
  1341 	}
  1341 }
  1342 }
  1342 
  1343 
       
  1344 
       
  1345 void
       
  1346 sigchld(int signal) {
       
  1347 	while(0 < waitpid(-1, NULL, WNOHANG));
       
  1348 }
       
  1349 
  1343 void
  1350 void
  1344 spawn(const Arg *arg) {
  1351 spawn(const Arg *arg) {
  1345 	/* The double-fork construct avoids zombie processes and keeps the code
  1352 	signal(SIGCHLD, sigchld);
  1346 	 * clean from stupid signal handlers. */
       
  1347 	if(fork() == 0) {
  1353 	if(fork() == 0) {
  1348 		if(fork() == 0) {
  1354 		if(dpy)
  1349 			if(dpy)
  1355 			close(ConnectionNumber(dpy));
  1350 				close(ConnectionNumber(dpy));
  1356 		setsid();
  1351 			setsid();
  1357 		execvp(((char **)arg->v)[0], (char **)arg->v);
  1352 			execvp(((char **)arg->v)[0], (char **)arg->v);
  1358 		fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
  1353 			fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
  1359 		perror(" failed");
  1354 			perror(" failed");
       
  1355 		}
       
  1356 		exit(0);
  1360 		exit(0);
  1357 	}
  1361 	}
  1358 	wait(0);
       
  1359 }
  1362 }
  1360 
  1363 
  1361 void
  1364 void
  1362 tag(const Arg *arg) {
  1365 tag(const Arg *arg) {
  1363 	if(sel && arg->ui & TAGMASK) {
  1366 	if(sel && arg->ui & TAGMASK) {