source: trunk/sys/dietlibc/execlp.c @ 1

Last change on this file since 1 was 1, checked in by alain, 5 years ago

First import

File size: 544 bytes
Line 
1#include <stdarg.h>
2#include <unistd.h>
3#include <errno.h>
4#include <stdlib.h>
5#include "dietfeatures.h"
6
7int execlp(const char* file, const char *arg,...) {
8  va_list ap,bak;
9  int n,i;
10  char **argv,*tmp;
11  va_start(ap, arg);
12  va_copy(bak,ap);
13  n=2;
14  while ((tmp=va_arg(ap,char *)))
15    ++n;
16  va_end (ap);
17  if ((argv=(char **)alloca(n*sizeof(char*)))) {
18    argv[0]=(char*)arg;
19    for (i=0; i<n; ++i)
20      argv[i+1]=va_arg(bak,char *);
21    va_end (bak);
22    return execvp(file,argv);
23  }
24  va_end (bak);
25  errno=ENOMEM;
26  return -1;
27}
Note: See TracBrowser for help on using the repository browser.