dwm-meillo
diff util.c @ 5:e5018cae273f
added several other stuff
author | Anselm R. Garbe <garbeam@wmii.de> |
---|---|
date | Mon, 10 Jul 2006 22:16:48 +0200 |
parents | e969f3575b7a |
children | e0cefb3981c8 |
line diff
1.1 --- a/util.c Mon Jul 10 19:47:35 2006 +0200 1.2 +++ b/util.c Mon Jul 10 22:16:48 2006 +0200 1.3 @@ -7,6 +7,11 @@ 1.4 #include <stdio.h> 1.5 #include <stdlib.h> 1.6 #include <string.h> 1.7 +#include <sys/types.h> 1.8 +#include <sys/wait.h> 1.9 +#include <unistd.h> 1.10 + 1.11 +#include "util.h" 1.12 1.13 void 1.14 error(char *errstr, ...) { 1.15 @@ -75,3 +80,21 @@ 1.16 *p1 = *p2; 1.17 *p2 = tmp; 1.18 } 1.19 + 1.20 +void 1.21 +spawn(Display *dpy, const char *shell, const char *cmd) 1.22 +{ 1.23 + if(!cmd || !shell) 1.24 + return; 1.25 + if(fork() == 0) { 1.26 + if(fork() == 0) { 1.27 + if(dpy) 1.28 + close(ConnectionNumber(dpy)); 1.29 + execl(shell, shell, "-c", cmd, (const char *)0); 1.30 + fprintf(stderr, "gridwm: execl %s", shell); 1.31 + perror(" failed"); 1.32 + } 1.33 + exit (0); 1.34 + } 1.35 + wait(0); 1.36 +}