blob: 5eed886e716fa9721bf953b877df19a89bd5718f [file] [log] [blame]
Rich Felker0b44a032011-02-12 00:22:29 -05001#include <unistd.h>
2#include <stdarg.h>
3
Rich Felkere6bac872011-04-27 16:06:33 -04004int execlp(const char *file, const char *argv0, ...)
Rich Felker0b44a032011-02-12 00:22:29 -05005{
6 int argc;
7 va_list ap;
Rich Felkere6bac872011-04-27 16:06:33 -04008 va_start(ap, argv0);
9 for (argc=1; va_arg(ap, const char *); argc++);
Rich Felker0b44a032011-02-12 00:22:29 -050010 va_end(ap);
11 {
12 int i;
13 char *argv[argc+1];
Rich Felkere6bac872011-04-27 16:06:33 -040014 va_start(ap, argv0);
15 argv[0] = (char *)argv0;
16 for (i=1; i<argc; i++)
Rich Felker0b44a032011-02-12 00:22:29 -050017 argv[i] = va_arg(ap, char *);
18 argv[i] = NULL;
Szabolcs Nagyc3a43b32013-10-07 13:24:00 +000019 va_end(ap);
Rich Felker0b44a032011-02-12 00:22:29 -050020 return execvp(file, argv);
21 }
22}