comparison 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
comparison
equal deleted inserted replaced
4:991bd8b0771e 5:e5018cae273f
5 5
6 #include <stdarg.h> 6 #include <stdarg.h>
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, ...) {
13 va_list ap; 18 va_list ap;
14 va_start(ap, errstr); 19 va_start(ap, errstr);
73 { 78 {
74 void *tmp = *p1; 79 void *tmp = *p1;
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 }