LibC: Implement execle()

This commit is contained in:
Jelle Raaijmakers 2021-06-04 01:47:17 +02:00 committed by Andreas Kling
parent 0e990a4be8
commit 7f4a1bc11e
Notes: sideshowbarker 2024-07-18 16:55:18 +09:00
2 changed files with 21 additions and 0 deletions

View file

@ -160,6 +160,26 @@ int execl(const char* filename, const char* arg0, ...)
return execve(filename, const_cast<char* const*>(args.data()), environ);
}
int execle(char const* filename, char const* arg0, ...)
{
Vector<char const*> args;
args.append(arg0);
va_list ap;
va_start(ap, arg0);
char const* arg;
do {
arg = va_arg(ap, char const*);
args.append(arg);
} while (arg);
auto argv = const_cast<char* const*>(args.data());
auto envp = const_cast<char* const*>(va_arg(ap, char* const*));
va_end(ap);
return execve(filename, argv, envp);
}
int execlp(const char* filename, const char* arg0, ...)
{
Vector<const char*, 16> args;

View file

@ -49,6 +49,7 @@ int execve(const char* filename, char* const argv[], char* const envp[]);
int execvpe(const char* filename, char* const argv[], char* const envp[]);
int execvp(const char* filename, char* const argv[]);
int execl(const char* filename, const char* arg, ...);
int execle(const char* filename, const char* arg, ...);
int execlp(const char* filename, const char* arg, ...);
int chroot(const char* path);
int chroot_with_mount_flags(const char* path, int mount_flags);