Hi,

I've attached a patch against hg tip that makes spawn() use a
NULL-terminated char pointer array for the argument, which is
execvp'd directly instead of going through the shell.

Regards,
Peter
diff -r f0c900871c87 config.def.h
--- a/config.def.h      Mon Jun 09 11:24:10 2008 +0200
+++ b/config.def.h      Mon Jun 09 14:45:27 2008 +0200
@@ -42,8 +42,8 @@
 
 Key keys[] = {
        /* modifier                     key        function        argument */
-       { MODKEY,                       XK_p,      spawn,          (char 
*)"exec dmenu_run -fn '"FONT"' -nb '"NORMBGCOLOR"' -nf '"NORMFGCOLOR"' -sb 
'"SELBGCOLOR"' -sf '"SELFGCOLOR"'" },
-       { MODKEY|ShiftMask,             XK_Return, spawn,          (char 
*)"exec uxterm" },
+       { MODKEY,                       XK_p,      spawn,          (char 
*[]){"dmenu_run", "-fn", FONT, "-nb", NORMBGCOLOR, "-nf", NORMFGCOLOR, "-sb", 
SELBGCOLOR, "-sf", SELFGCOLOR, NULL} },
+       { MODKEY|ShiftMask,             XK_Return, spawn,          (char 
*[]){"uxterm", NULL} },
        { MODKEY,                       XK_b,      togglebar,      NULL },
        { MODKEY,                       XK_j,      focusnext,      NULL },
        { MODKEY,                       XK_k,      focusprev,      NULL },
diff -r f0c900871c87 dwm.c
--- a/dwm.c     Mon Jun 09 11:24:10 2008 +0200
+++ b/dwm.c     Mon Jun 09 14:45:27 2008 +0200
@@ -1387,10 +1387,6 @@
 
 void
 spawn(const void *arg) {
-       static char *shell = NULL;
-
-       if(!shell && !(shell = getenv("SHELL")))
-               shell = "/bin/sh";
        /* The double-fork construct avoids zombie processes and keeps the code
         * clean from stupid signal handlers. */
        if(fork() == 0) {
@@ -1398,8 +1394,8 @@
                        if(dpy)
                                close(ConnectionNumber(dpy));
                        setsid();
-                       execl(shell, shell, "-c", (char *)arg, (char *)NULL);
-                       fprintf(stderr, "dwm: execl '%s -c %s'", shell, (char 
*)arg);
+                       execvp(((char **)arg)[0], (char **)arg);
+                       fprintf(stderr, "dwm: execvp %s", ((char **)arg)[0]);
                        perror(" failed");
                }
                exit(0);

Reply via email to