Retro68/gcc/newlib/libc/posix/execl.c

40 lines
768 B
C
Raw Normal View History

2017-04-11 21:13:36 +00:00
#ifndef _NO_EXECVE
/* execl.c */
/* This and the other exec*.c files in this directory require
the target to provide the _execve syscall. */
#include <_ansi.h>
#include <unistd.h>
/* Only deal with a pointer to environ, to work around subtle bugs with shared
libraries and/or small data systems where the user declares his own
'environ'. */
static char ***p_environ = &environ;
#include <stdarg.h>
int
2018-12-28 15:30:48 +00:00
execl (const char *path,
const char *arg0, ...)
2017-04-11 21:13:36 +00:00
{
int i;
va_list args;
2018-12-28 15:30:48 +00:00
const char *argv[256];
2017-04-11 21:13:36 +00:00
va_start (args, arg0);
argv[0] = arg0;
i = 1;
do
2018-12-28 15:30:48 +00:00
argv[i] = va_arg (args, const char *);
2017-04-11 21:13:36 +00:00
while (argv[i++] != NULL);
va_end (args);
2018-12-28 15:30:48 +00:00
return _execve (path, (char * const *) argv, *p_environ);
2017-04-11 21:13:36 +00:00
}
#endif /* !_NO_EXECVE */