This commit is contained in:
parent
64bca780a7
commit
47ee52dc0a
@ -31,6 +31,9 @@ extern "C"
|
||||
/* Replace the current process with another one. On success, does not return. */
|
||||
int execv(const char* path, char* const* argv);
|
||||
|
||||
/* Replace the current process with another one. On success, does not return. */
|
||||
int execl(const char* path, const char* arg, ...);
|
||||
|
||||
int execve(const char*, char* const*, char* const*);
|
||||
int execvp(const char*, char* const*);
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
#include <luna/Vector.h>
|
||||
|
||||
#include <bits/errno-return.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
@ -31,6 +33,26 @@ extern "C"
|
||||
__errno_return(rc, int);
|
||||
}
|
||||
|
||||
int execl(const char* path, const char* arg, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, arg);
|
||||
|
||||
Vector<char*> args;
|
||||
if (args.try_append(const_cast<char*>(arg)).has_error()) return -1;
|
||||
|
||||
while (true)
|
||||
{
|
||||
char* str = va_arg(ap, char*);
|
||||
if (args.try_append(str).has_error()) return -1;
|
||||
if (!str) break;
|
||||
}
|
||||
|
||||
va_end(ap);
|
||||
|
||||
return execv(path, args.data());
|
||||
}
|
||||
|
||||
long syscall(long num, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
Loading…
Reference in New Issue
Block a user