dwm.c
changeset 1478 cf5bb4e72804
parent 1477 aefd753cfe9b
child 1479 31cb815bac41
equal deleted inserted replaced
1477:aefd753cfe9b 1478:cf5bb4e72804
   205 static void setclientstate(Client *c, long state);
   205 static void setclientstate(Client *c, long state);
   206 static void setlayout(const Arg *arg);
   206 static void setlayout(const Arg *arg);
   207 static void setmfact(const Arg *arg);
   207 static void setmfact(const Arg *arg);
   208 static void setup(void);
   208 static void setup(void);
   209 static void showhide(Client *c);
   209 static void showhide(Client *c);
   210 static void sigchld(int signal);
   210 static void sigchld(int unused);
   211 static void spawn(const Arg *arg);
   211 static void spawn(const Arg *arg);
   212 static void tag(const Arg *arg);
   212 static void tag(const Arg *arg);
   213 static void tagmon(const Arg *arg);
   213 static void tagmon(const Arg *arg);
   214 static int textnw(const char *text, unsigned int len);
   214 static int textnw(const char *text, unsigned int len);
   215 static void tile(Monitor *);
   215 static void tile(Monitor *);
  1425 void
  1425 void
  1426 setup(void) {
  1426 setup(void) {
  1427 	unsigned int i;
  1427 	unsigned int i;
  1428 	int w;
  1428 	int w;
  1429 	XSetWindowAttributes wa;
  1429 	XSetWindowAttributes wa;
       
  1430 
       
  1431 	/* clean up any zombies immediately */
       
  1432 	signal(SIGCHLD, sigchld);
       
  1433 	sigchld(0);
  1430 
  1434 
  1431 	/* init screen */
  1435 	/* init screen */
  1432 	screen = DefaultScreen(dpy);
  1436 	screen = DefaultScreen(dpy);
  1433 	root = RootWindow(dpy, screen);
  1437 	root = RootWindow(dpy, screen);
  1434 	initfont(font);
  1438 	initfont(font);
  1494 	}
  1498 	}
  1495 }
  1499 }
  1496 
  1500 
  1497 
  1501 
  1498 void
  1502 void
  1499 sigchld(int signal) {
  1503 sigchld(int unused) {
  1500 	while(0 < waitpid(-1, NULL, WNOHANG));
  1504 	while(0 < waitpid(-1, NULL, WNOHANG));
       
  1505 	signal(SIGCHLD, sigchld);
  1501 }
  1506 }
  1502 
  1507 
  1503 void
  1508 void
  1504 spawn(const Arg *arg) {
  1509 spawn(const Arg *arg) {
  1505 	signal(SIGCHLD, sigchld);
       
  1506 	if(fork() == 0) {
  1510 	if(fork() == 0) {
  1507 		if(dpy)
  1511 		if(dpy)
  1508 			close(ConnectionNumber(dpy));
  1512 			close(ConnectionNumber(dpy));
  1509 		setsid();
  1513 		setsid();
  1510 		execvp(((char **)arg->v)[0], (char **)arg->v);
  1514 		execvp(((char **)arg->v)[0], (char **)arg->v);