dwm-meillo

diff util.c @ 14:5c078b66347b

added bar event timer
author Anselm R. Garbe <garbeam@wmii.de>
date Tue, 11 Jul 2006 18:15:11 +0200
parents ea9c08ec4b48
children 00d4d52b231f
line diff
     1.1 --- a/util.c	Tue Jul 11 16:14:22 2006 +0200
     1.2 +++ b/util.c	Tue Jul 11 18:15:11 2006 +0200
     1.3 @@ -14,8 +14,6 @@
     1.4  
     1.5  #include "util.h"
     1.6  
     1.7 -static char *shell = NULL;
     1.8 -
     1.9  void
    1.10  error(char *errstr, ...) {
    1.11  	va_list ap;
    1.12 @@ -85,21 +83,17 @@
    1.13  }
    1.14  
    1.15  void
    1.16 -spawn(Display *dpy, const char *cmd)
    1.17 +spawn(Display *dpy, char *argv[])
    1.18  {
    1.19 -	if(!shell && !(shell = getenv("SHELL")))
    1.20 -		shell = "/bin/sh";
    1.21 -
    1.22 -	if(!cmd)
    1.23 +	if(!argv || !argv[0])
    1.24  		return;
    1.25  	if(fork() == 0) {
    1.26  		if(fork() == 0) {
    1.27  			if(dpy)
    1.28  				close(ConnectionNumber(dpy));
    1.29  			setsid();
    1.30 -			fprintf(stderr, "gridwm: execlp %s %s -c %s", shell, shell, cmd);
    1.31 -			execlp(shell, shell, "-c", cmd, NULL);
    1.32 -			fprintf(stderr, "gridwm: execlp %s", cmd);
    1.33 +			execvp(argv[0], argv);
    1.34 +			fprintf(stderr, "gridwm: execvp %s", argv[0]);
    1.35  			perror(" failed");
    1.36  		}
    1.37  		exit (0);
    1.38 @@ -108,15 +102,12 @@
    1.39  }
    1.40  
    1.41  void
    1.42 -pipe_spawn(char *buf, unsigned int len, Display *dpy, const char *cmd)
    1.43 +pipe_spawn(char *buf, unsigned int len, Display *dpy, char *argv[])
    1.44  {
    1.45  	unsigned int l, n;
    1.46  	int pfd[2];
    1.47  
    1.48 -	if(!shell && !(shell = getenv("SHELL")))
    1.49 -		shell = "/bin/sh";
    1.50 -
    1.51 -	if(!cmd)
    1.52 +	if(!argv || !argv[0])
    1.53  		return;
    1.54  
    1.55  	if(pipe(pfd) == -1) {
    1.56 @@ -131,8 +122,8 @@
    1.57  		dup2(pfd[1], STDOUT_FILENO);
    1.58  		close(pfd[0]);
    1.59  		close(pfd[1]);
    1.60 -		execlp(shell, shell, "-c", cmd, NULL);
    1.61 -		fprintf(stderr, "gridwm: execlp %s", cmd);
    1.62 +		execvp(argv[0], argv);
    1.63 +		fprintf(stderr, "gridwm: execvp %s", argv[0]);
    1.64  		perror(" failed");
    1.65  	}
    1.66  	else {