Files
vlibc/src/process/execlp.c
T

47 lines
960 B
C

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdarg.h>
#include <unistd.h>
#include "../internal/syscall.h"
/*
* execlp: like execl, but the file is located through PATH (see
* execvp.c). The argv staging uses a VLA; the POSIX signature is fixed
* and the adjacent-parameter check is waived per the house NOLINT
* convention.
*/
// NOLINTBEGIN(bugprone-easily-swappable-parameters)
int
execlp(const char *file, const char *arg0, ...)
{
va_list ap;
int argc;
int i;
int ret;
va_start(ap, arg0);
argc = 1;
while (va_arg(ap, const char *) != 0)
{
argc++;
}
va_end(ap);
{
char *argv[argc + 1];
argv[0] = (char *)arg0;
va_start(ap, arg0);
for (i = 1; i <= argc; i++)
{
argv[i] = va_arg(ap, char *);
}
va_end(ap);
ret = execvp(file, argv);
}
return ret;
}
// NOLINTEND(bugprone-easily-swappable-parameters)