diff options
Diffstat (limited to 'util.c')
| -rw-r--r-- | util.c | 23 |
1 files changed, 23 insertions, 0 deletions
| @@ -7,6 +7,11 @@ | |||
| 7 | #include <stdio.h> | 7 | #include <stdio.h> |
| 8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
| 9 | #include <string.h> | 9 | #include <string.h> |
| 10 | #include <sys/types.h> | ||
| 11 | #include <sys/wait.h> | ||
| 12 | #include <unistd.h> | ||
| 13 | |||
| 14 | #include "util.h" | ||
| 10 | 15 | ||
| 11 | void | 16 | void |
| 12 | error(char *errstr, ...) { | 17 | error(char *errstr, ...) { |
| @@ -75,3 +80,21 @@ swap(void **p1, void **p2) | |||
| 75 | *p1 = *p2; | 80 | *p1 = *p2; |
| 76 | *p2 = tmp; | 81 | *p2 = tmp; |
| 77 | } | 82 | } |
| 83 | |||
| 84 | void | ||
| 85 | spawn(Display *dpy, const char *shell, const char *cmd) | ||
| 86 | { | ||
| 87 | if(!cmd || !shell) | ||
| 88 | return; | ||
| 89 | if(fork() == 0) { | ||
| 90 | if(fork() == 0) { | ||
| 91 | if(dpy) | ||
| 92 | close(ConnectionNumber(dpy)); | ||
| 93 | execl(shell, shell, "-c", cmd, (const char *)0); | ||
| 94 | fprintf(stderr, "gridwm: execl %s", shell); | ||
| 95 | perror(" failed"); | ||
| 96 | } | ||
| 97 | exit (0); | ||
| 98 | } | ||
| 99 | wait(0); | ||
| 100 | } | ||
