equal
deleted
inserted
replaced
41 } |
41 } |
42 |
42 |
43 void |
43 void |
44 spawn(Arg *arg) |
44 spawn(Arg *arg) |
45 { |
45 { |
46 char **argv = (char **)arg->argv; |
46 static char *shell = NULL; |
47 |
47 |
48 if(!argv || !argv[0]) |
48 if(!shell && !(shell = getenv("SHELL"))) |
|
49 shell = "/bin/sh"; |
|
50 |
|
51 if(!arg->cmd) |
49 return; |
52 return; |
50 if(fork() == 0) { |
53 if(fork() == 0) { |
51 if(fork() == 0) { |
54 if(fork() == 0) { |
52 if(dpy) |
55 if(dpy) |
53 close(ConnectionNumber(dpy)); |
56 close(ConnectionNumber(dpy)); |
54 setsid(); |
57 setsid(); |
55 execvp(argv[0], argv); |
58 execl(shell, shell, "-c", arg->cmd, NULL); |
56 fprintf(stderr, "dwm: execvp %s", argv[0]); |
59 fprintf(stderr, "dwm: execl '%s'", arg->cmd); |
57 perror(" failed"); |
60 perror(" failed"); |
58 } |
61 } |
59 exit(0); |
62 exit(0); |
60 } |
63 } |
61 wait(0); |
64 wait(0); |