wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

spawn3l.c (505B)


      1 /* Copyright ©2008-2010 Kris Maglione <maglione.k at Gmail>
      2  * See LICENSE file for license details.
      3  */
      4 #include <fmt.h>
      5 #include "util.h"
      6 
      7 int
      8 spawn3l(int fd[3], const char *file, ...) {
      9 	va_list ap;
     10 	char **argv;
     11 	int i, n;
     12 
     13 	va_start(ap, file);
     14 	for(n=0; va_arg(ap, char*); n++)
     15 		;
     16 	va_end(ap);
     17 
     18 	argv = emalloc((n+1) * sizeof *argv);
     19 	va_start(ap, file);
     20 	quotefmtinstall();
     21 	for(i=0; i <= n; i++)
     22 		argv[i] = va_arg(ap, char*);
     23 	va_end(ap);
     24 
     25 	i = spawn3(fd, file, argv);
     26 	free(argv);
     27 	return i;
     28 }