source: trunk/sys/dietlibc/execl.c @ 98

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

First import

File size: 672 bytes
Line 
1#include <stdarg.h>
2#include <unistd.h>
3#include <errno.h>
4#include <stdlib.h>
5#include "dietfeatures.h"
6
7
8int execl(const char *path, const char *arg, ...){
9//int execl( const char *path,...) {
10  va_list ap,bak;
11  int n,i;
12  char **argv,*tmp;
13  va_start(ap, arg);
14  va_copy(bak,ap);
15  n=3;
16  while ((tmp=va_arg(ap,char *)))
17    ++n;
18  va_end (ap);
19  if ((argv=(char **)alloca(n*sizeof(char*)))) {
20
21    /* Preapre args */
22    argv[0]   = (char*)arg;/* arg should be equal to path */
23    for (i=1; i<n-1; ++i)
24            argv[i]=va_arg(bak,char *);
25    va_end (bak);
26    argv[n-1] = NULL;
27
28    return execve(path,argv,environ);
29  }
30  va_end (bak);
31  errno=ENOMEM;
32  return -1;
33}
Note: See TracBrowser for help on using the repository browser.