[dwm] patch to not reparent children to init

From: Neale Pickett <neale_AT_woozle.org>
Date: Tue, 04 Nov 2008 10:09:54 -0700

Reparenting everything to init with the double-fork is a nightmare on a
many-user machine, especially when I'm logged in more than once. pstree
becomes useless. This sets up a SIGCHLD handler and only forks once.
Adds 2 SLOC, but surely there's some reason the double-fork is there that
I'm just missing...

void
sigchld(int signal)
{
  while (0 < waitpid(-1, NULL, WNOHANG));
}

void
spawn(const Arg *arg)
{
  signal(SIGCHLD, sigchld);
  if (fork() == 0) {
    if (dpy) close(ConnectionNumber(dpy));
    setsid();
    execvp(((char **)arg->v)[0], (char **)arg->v);
    fprintf(stderr, "dwm: execvp %s", ((char **)arg->v)[0]);
    perror(" failed");
    exit(0);
  }
}
Received on Tue Nov 04 2008 - 17:09:54 UTC

This archive was generated by hypermail 2.2.0 : Tue Nov 04 2008 - 17:24:04 UTC