diff options
-rw-r--r-- | dwm.c | 12 |
1 files changed, 4 insertions, 8 deletions
@@ -28,6 +28,7 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <spawn.h> #include <sys/types.h> #include <sys/wait.h> #include <X11/cursorfont.h> @@ -1954,16 +1955,12 @@ sigchld(int unused) while (0 < waitpid(-1, NULL, WNOHANG)); } +extern char **environ; + void spawn(const Arg *arg) { - if (fork() == 0) { - if (dpy) - close(ConnectionNumber(dpy)); - setsid(); - execvp(((char **)arg->v)[0], (char **)arg->v); - die("dwm: execvp '%s' failed:", ((char **)arg->v)[0]); - } + posix_spawnp(NULL, ((char **)arg->v)[0], NULL, NULL, (char **)arg->v, environ); } void @@ -2683,4 +2680,3 @@ main(int argc, char *argv[]) XCloseDisplay(dpy); return EXIT_SUCCESS; } - |