diff options
| author | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-10 22:16:48 +0200 |
|---|---|---|
| committer | Anselm R. Garbe <garbeam@wmii.de> | 2006-07-10 22:16:48 +0200 |
| commit | 439e15d09f6fa9271d3b49ef97194f0c80ebe161 (patch) | |
| tree | 0f1abd8629f3fc226bb313ce29f00b6b8424f375 /util.c | |
| parent | renamed gridmenu.c into menu.c (diff) | |
| download | dwm-439e15d09f6fa9271d3b49ef97194f0c80ebe161.tar.gz dwm-439e15d09f6fa9271d3b49ef97194f0c80ebe161.zip | |
added several other stuff
Diffstat (limited to '')
| -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 | } | ||
