9base

revived minimalist port of Plan 9 userland to Unix
git clone git://git.suckless.org/9base
Log | Files | Refs | README | LICENSE

execl.c (393B)


      1 #include <u.h>
      2 #include <libc.h>
      3 
      4 int
      5 execl(char *prog, ...)
      6 {
      7 	int i;
      8 	va_list arg;
      9 	char **argv;
     10 
     11 	va_start(arg, prog);
     12 	for(i=0; va_arg(arg, char*) != nil; i++)
     13 		;
     14 	va_end(arg);
     15 
     16 	argv = malloc((i+1)*sizeof(char*));
     17 	if(argv == nil)
     18 		return -1;
     19 
     20 	va_start(arg, prog);
     21 	for(i=0; (argv[i] = va_arg(arg, char*)) != nil; i++)
     22 		;
     23 	va_end(arg);
     24 
     25 	exec(prog, argv);
     26 	free(argv);
     27 	return -1;
     28 }
     29