Compare commits
21 Commits
6e22261116
...
7541540fd3
Author | SHA1 | Date | |
---|---|---|---|
7541540fd3 | |||
c477f85c19 | |||
dceb6be559 | |||
9500d14087 | |||
9f9b9a17bc | |||
62802f6e1c | |||
662d061f89 | |||
3315a79de0 | |||
92bff6deb4 | |||
d8c30c40a3 | |||
e5e2a7bda6 | |||
52dd5501f3 | |||
f50e153313 | |||
ffb70932f3 | |||
25bcba413f | |||
064ff307dc | |||
454a586296 | |||
67e7633ffd | |||
c3c0fc71f1 | |||
3e88a5a689 | |||
9f7dc7ae79 |
@ -27,4 +27,3 @@ luna_app(ipc-test.cpp ipc-test)
|
|||||||
luna_app(mount.cpp mount)
|
luna_app(mount.cpp mount)
|
||||||
luna_app(umount.cpp umount)
|
luna_app(umount.cpp umount)
|
||||||
luna_app(ps.cpp ps)
|
luna_app(ps.cpp ps)
|
||||||
luna_app(time.cpp time)
|
|
||||||
|
@ -86,11 +86,7 @@ Result<int> luna_main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto cmd = TRY(input_file->read_line());
|
auto cmd = TRY(input_file->read_line());
|
||||||
if (cmd.is_empty())
|
if (cmd.is_empty()) break;
|
||||||
{
|
|
||||||
puts("exit");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strspn(cmd.chars(), " \n") == cmd.length()) continue;
|
if (strspn(cmd.chars(), " \n") == cmd.length()) continue;
|
||||||
|
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
#include <os/ArgumentParser.h>
|
|
||||||
#include <os/File.h>
|
|
||||||
#include <os/Process.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
|
|
||||||
Result<int> luna_main(int argc, char** argv)
|
|
||||||
{
|
|
||||||
Vector<StringView> command;
|
|
||||||
|
|
||||||
os::ArgumentParser parser;
|
|
||||||
parser.add_description("Time a command.");
|
|
||||||
parser.add_system_program_info("time"_sv);
|
|
||||||
parser.set_vector_argument(command, true);
|
|
||||||
TRY(parser.parse(argc, argv));
|
|
||||||
|
|
||||||
auto pid = TRY(os::Process::fork());
|
|
||||||
|
|
||||||
if (pid == 0)
|
|
||||||
{
|
|
||||||
TRY(os::Process::exec(command[0], command.slice()));
|
|
||||||
unreachable();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (waitpid(pid, nullptr, 0) < 0)
|
|
||||||
{
|
|
||||||
perror("waitpid");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct rusage usage;
|
|
||||||
if (getrusage(RUSAGE_CHILDREN, &usage) < 0)
|
|
||||||
{
|
|
||||||
perror("getrusage");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto cmdline = TRY(String::join(command, " "));
|
|
||||||
|
|
||||||
os::println("%s %d.%.2ds user %d.%.2ds system"_sv, cmdline.chars(), usage.ru_utime.tv_sec,
|
|
||||||
usage.ru_utime.tv_usec / 10000, usage.ru_stime.tv_sec, usage.ru_stime.tv_usec / 10000);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -39,7 +39,6 @@ set(SOURCES
|
|||||||
src/sys/link.cpp
|
src/sys/link.cpp
|
||||||
src/sys/uname.cpp
|
src/sys/uname.cpp
|
||||||
src/sys/mount.cpp
|
src/sys/mount.cpp
|
||||||
src/sys/resource.cpp
|
|
||||||
src/fs/VFS.cpp
|
src/fs/VFS.cpp
|
||||||
src/fs/Pipe.cpp
|
src/fs/Pipe.cpp
|
||||||
src/fs/Mount.cpp
|
src/fs/Mount.cpp
|
||||||
|
@ -28,9 +28,9 @@ Result<u64> sys_pstat(Registers*, SyscallArgs args)
|
|||||||
proc.ps_egid = thread->auth.egid;
|
proc.ps_egid = thread->auth.egid;
|
||||||
proc.ps_state = (int)thread->state;
|
proc.ps_state = (int)thread->state;
|
||||||
proc.ps_flags = thread->is_kernel ? PS_FLAG_KRNL : 0;
|
proc.ps_flags = thread->is_kernel ? PS_FLAG_KRNL : 0;
|
||||||
set_timespec(proc.ps_time, thread->user_ticks_self + thread->kernel_ticks_self);
|
set_timespec(proc.ps_time, thread->ticks);
|
||||||
set_timespec(proc.ps_ktime, thread->kernel_ticks_self);
|
set_timespec(proc.ps_ktime, thread->ticks_in_kernel);
|
||||||
set_timespec(proc.ps_utime, thread->kernel_ticks_children);
|
set_timespec(proc.ps_utime, thread->ticks_in_user);
|
||||||
strlcpy(proc.ps_name, thread->name.chars(), sizeof(proc.ps_name));
|
strlcpy(proc.ps_name, thread->name.chars(), sizeof(proc.ps_name));
|
||||||
strlcpy(proc.ps_cwd, thread->current_directory_path.is_empty() ? "/" : thread->current_directory_path.chars(),
|
strlcpy(proc.ps_cwd, thread->current_directory_path.is_empty() ? "/" : thread->current_directory_path.chars(),
|
||||||
sizeof(proc.ps_cwd));
|
sizeof(proc.ps_cwd));
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
#include "memory/MemoryManager.h"
|
|
||||||
#include "sys/Syscall.h"
|
|
||||||
#include "thread/Scheduler.h"
|
|
||||||
#include <bits/rusage.h>
|
|
||||||
|
|
||||||
static void ticks_to_rusage(struct rusage* ru, u64 sticks, u64 uticks)
|
|
||||||
{
|
|
||||||
ru->ru_stime.tv_sec = sticks / 1000;
|
|
||||||
ru->ru_stime.tv_usec = (sticks % 1000) * 1000;
|
|
||||||
ru->ru_utime.tv_sec = uticks / 1000;
|
|
||||||
ru->ru_utime.tv_usec = (uticks % 1000) * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result<u64> sys_getrusage(Registers*, SyscallArgs args)
|
|
||||||
{
|
|
||||||
int who = (int)args[0];
|
|
||||||
struct rusage* ru = (struct rusage*)args[1];
|
|
||||||
|
|
||||||
auto* current = Scheduler::current();
|
|
||||||
|
|
||||||
struct rusage kru;
|
|
||||||
switch (who)
|
|
||||||
{
|
|
||||||
case RUSAGE_SELF: ticks_to_rusage(&kru, current->kernel_ticks_self, current->user_ticks_self); break;
|
|
||||||
case RUSAGE_CHILDREN: ticks_to_rusage(&kru, current->kernel_ticks_children, current->user_ticks_children); break;
|
|
||||||
default: return err(EINVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!MemoryManager::copy_to_user_typed(ru, &kru)) return err(EFAULT);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -50,9 +50,6 @@ Result<u64> sys_waitpid(Registers*, SyscallArgs args)
|
|||||||
int status = (int)thread->status;
|
int status = (int)thread->status;
|
||||||
u64 id = thread->id;
|
u64 id = thread->id;
|
||||||
|
|
||||||
current->user_ticks_children += thread->user_ticks_self;
|
|
||||||
current->kernel_ticks_children += thread->kernel_ticks_self;
|
|
||||||
|
|
||||||
thread->state = ThreadState::Dying;
|
thread->state = ThreadState::Dying;
|
||||||
Scheduler::signal_reap_thread();
|
Scheduler::signal_reap_thread();
|
||||||
|
|
||||||
|
@ -261,9 +261,11 @@ namespace Scheduler
|
|||||||
{
|
{
|
||||||
CPU::disable_interrupts();
|
CPU::disable_interrupts();
|
||||||
|
|
||||||
if (is_in_kernel(regs)) g_current->kernel_ticks_self++;
|
g_current->ticks++;
|
||||||
|
|
||||||
|
if (is_in_kernel(regs)) g_current->ticks_in_kernel++;
|
||||||
else
|
else
|
||||||
g_current->user_ticks_self++;
|
g_current->ticks_in_user++;
|
||||||
|
|
||||||
g_current->ticks_left--;
|
g_current->ticks_left--;
|
||||||
|
|
||||||
@ -340,11 +342,11 @@ namespace Scheduler
|
|||||||
|
|
||||||
for (const auto* thread : g_threads)
|
for (const auto* thread : g_threads)
|
||||||
{
|
{
|
||||||
kdbgln("%p %c [%-20s] %4zu, parent = (%-18p,%zu), state = %d, ticks: (k:%04zu,u:%04zu), status = "
|
kdbgln("%p %c [%-20s] %4zu, parent = (%-18p,%zu), state = %d, ticks: (t:%04zu,k:%04zu,u:%04zu), status = "
|
||||||
"%d, cwd = %s",
|
"%d, cwd = %s",
|
||||||
thread, thread->is_kernel ? 'k' : 'u', thread->name.chars(), thread->id, thread->parent,
|
thread, thread->is_kernel ? 'k' : 'u', thread->name.chars(), thread->id, thread->parent,
|
||||||
thread->parent ? thread->parent->id : 0, (int)thread->state, thread->kernel_ticks_self,
|
thread->parent ? thread->parent->id : 0, (int)thread->state, thread->ticks, thread->ticks_in_kernel,
|
||||||
thread->user_ticks_self, thread->status,
|
thread->ticks_in_user, thread->status,
|
||||||
thread->current_directory_path.is_empty() ? "/" : thread->current_directory_path.chars());
|
thread->current_directory_path.is_empty() ? "/" : thread->current_directory_path.chars());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,10 +59,9 @@ struct Thread : public LinkedListNode<Thread>
|
|||||||
|
|
||||||
Credentials auth;
|
Credentials auth;
|
||||||
|
|
||||||
u64 user_ticks_self = 0;
|
u64 ticks = 0;
|
||||||
u64 kernel_ticks_self = 0;
|
u64 ticks_in_user = 0;
|
||||||
u64 user_ticks_children = 0;
|
u64 ticks_in_kernel = 0;
|
||||||
u64 kernel_ticks_children = 0;
|
|
||||||
|
|
||||||
u64 ticks_left;
|
u64 ticks_left;
|
||||||
u64 sleep_ticks_left;
|
u64 sleep_ticks_left;
|
||||||
|
@ -26,7 +26,6 @@ set(SOURCES
|
|||||||
src/sys/utsname.cpp
|
src/sys/utsname.cpp
|
||||||
src/sys/mount.cpp
|
src/sys/mount.cpp
|
||||||
src/sys/pstat.cpp
|
src/sys/pstat.cpp
|
||||||
src/sys/resource.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(${LUNA_ARCH} STREQUAL "x86_64")
|
if(${LUNA_ARCH} STREQUAL "x86_64")
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
/* bits/rusage.h: The rusage structure. */
|
|
||||||
|
|
||||||
#ifndef _BITS_RUSAGE_H
|
|
||||||
#define _BITS_RUSAGE_H
|
|
||||||
|
|
||||||
#include <bits/timespec.h>
|
|
||||||
|
|
||||||
struct rusage
|
|
||||||
{
|
|
||||||
struct timeval ru_utime;
|
|
||||||
struct timeval ru_stime;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define RUSAGE_SELF 0
|
|
||||||
#define RUSAGE_CHILDREN 1
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,4 +1,4 @@
|
|||||||
/* bits/timespec.h: The timespec and timeval structures. */
|
/* bits/timespec.h: The timespec structure. */
|
||||||
|
|
||||||
#ifndef _BITS_TIMESPEC_H
|
#ifndef _BITS_TIMESPEC_H
|
||||||
#define _BITS_TIMESPEC_H
|
#define _BITS_TIMESPEC_H
|
||||||
@ -11,10 +11,4 @@ struct timespec
|
|||||||
long tv_nsec;
|
long tv_nsec;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct timeval
|
|
||||||
{
|
|
||||||
time_t tv_sec;
|
|
||||||
suseconds_t tv_usec;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
/* sys/resource.h: System resource management. */
|
|
||||||
|
|
||||||
#ifndef _SYS_RESOURCE_H
|
|
||||||
#define _SYS_RESOURCE_H
|
|
||||||
|
|
||||||
#include <bits/rusage.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Get this process or its children's resource usage. */
|
|
||||||
int getrusage(int who, struct rusage* ru);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -18,9 +18,6 @@ extern "C"
|
|||||||
/* Change the mode bits of a file. */
|
/* Change the mode bits of a file. */
|
||||||
int chmod(const char* path, mode_t mode);
|
int chmod(const char* path, mode_t mode);
|
||||||
|
|
||||||
/* Change the mode bits of a file descriptor. */
|
|
||||||
int fchmod(int fd, mode_t mode);
|
|
||||||
|
|
||||||
#pragma GCC push_options
|
#pragma GCC push_options
|
||||||
#pragma GCC diagnostic ignored "-Wshadow"
|
#pragma GCC diagnostic ignored "-Wshadow"
|
||||||
|
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
/* sys/time.h: POSIX time types. */
|
|
||||||
|
|
||||||
#ifndef _SYS_TIME_H
|
|
||||||
#define _SYS_TIME_H
|
|
||||||
|
|
||||||
#include <bits/attrs.h>
|
|
||||||
#include <bits/timespec.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Get the current time of day. */
|
|
||||||
__deprecated int gettimeofday(struct timeval* tp, void* timezone);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
@ -19,7 +19,6 @@ typedef __u64_t ino_t;
|
|||||||
typedef __u32_t uid_t;
|
typedef __u32_t uid_t;
|
||||||
typedef __u32_t gid_t;
|
typedef __u32_t gid_t;
|
||||||
typedef __u64_t nlink_t;
|
typedef __u64_t nlink_t;
|
||||||
typedef __i64_t suseconds_t;
|
|
||||||
|
|
||||||
typedef off_t fpos_t;
|
typedef off_t fpos_t;
|
||||||
|
|
||||||
|
@ -14,9 +14,6 @@
|
|||||||
#define STDOUT_FILENO 1
|
#define STDOUT_FILENO 1
|
||||||
#define STDERR_FILENO 2
|
#define STDERR_FILENO 2
|
||||||
|
|
||||||
#define _POSIX_CHOWN_RESTRICTED 200112L
|
|
||||||
#define _POSIX_SHELL 200112L
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@ -58,9 +55,6 @@ extern "C"
|
|||||||
/* Change the owner and group of a file. */
|
/* Change the owner and group of a file. */
|
||||||
int chown(const char* path, uid_t uid, gid_t gid);
|
int chown(const char* path, uid_t uid, gid_t gid);
|
||||||
|
|
||||||
/* Change the owner and group of a file descriptor. */
|
|
||||||
int fchown(int fd, uid_t uid, gid_t gid);
|
|
||||||
|
|
||||||
/* Replace the current process with another one. On success, does not return. */
|
/* Replace the current process with another one. On success, does not return. */
|
||||||
int execv(const char* path, char* const* argv);
|
int execv(const char* path, char* const* argv);
|
||||||
|
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
#include <bits/errno-return.h>
|
|
||||||
#include <sys/resource.h>
|
|
||||||
#include <sys/syscall.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
extern "C"
|
|
||||||
{
|
|
||||||
int getrusage(int who, struct rusage* ru)
|
|
||||||
{
|
|
||||||
long rc = syscall(SYS_getrusage, who, ru);
|
|
||||||
__errno_return(rc, int);
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,12 +18,6 @@ extern "C"
|
|||||||
__errno_return(rc, int);
|
__errno_return(rc, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fchmod(int fd, mode_t mode)
|
|
||||||
{
|
|
||||||
long rc = syscall(SYS_fchmodat, fd, "", mode, AT_EMPTY_PATH);
|
|
||||||
__errno_return(rc, int);
|
|
||||||
}
|
|
||||||
|
|
||||||
int stat(const char* path, struct stat* st)
|
int stat(const char* path, struct stat* st)
|
||||||
{
|
{
|
||||||
long rc = syscall(SYS_fstatat, AT_FDCWD, path, st, 0);
|
long rc = syscall(SYS_fstatat, AT_FDCWD, path, st, 0);
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
#include <bits/errno-return.h>
|
#include <bits/errno-return.h>
|
||||||
#include <luna/Check.h>
|
#include <luna/Check.h>
|
||||||
#include <luna/Format.h>
|
#include <luna/Format.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -150,21 +148,4 @@ extern "C"
|
|||||||
{
|
{
|
||||||
return asctime(localtime(tp));
|
return asctime(localtime(tp));
|
||||||
}
|
}
|
||||||
|
|
||||||
int gettimeofday(struct timeval* tp, void* timezone)
|
|
||||||
{
|
|
||||||
if (timezone)
|
|
||||||
{
|
|
||||||
fputs("gettimeofday: timezone was not NULL, abort\n", stderr);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct timespec ts;
|
|
||||||
if (clock_gettime(CLOCK_REALTIME, &ts) < 0) return -1;
|
|
||||||
|
|
||||||
tp->tv_sec = ts.tv_sec;
|
|
||||||
tp->tv_usec = ts.tv_nsec / 1000;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -148,12 +148,6 @@ extern "C"
|
|||||||
__errno_return(rc, int);
|
__errno_return(rc, int);
|
||||||
}
|
}
|
||||||
|
|
||||||
int fchown(int fd, uid_t uid, gid_t gid)
|
|
||||||
{
|
|
||||||
long rc = syscall(SYS_fchownat, fd, "", uid, gid, AT_EMPTY_PATH);
|
|
||||||
__errno_return(rc, int);
|
|
||||||
}
|
|
||||||
|
|
||||||
int execv(const char* path, char* const* argv)
|
int execv(const char* path, char* const* argv)
|
||||||
{
|
{
|
||||||
return execve(path, argv, environ);
|
return execve(path, argv, environ);
|
||||||
|
@ -55,9 +55,6 @@ class String
|
|||||||
/* Creates a single String consisting of a list of strings separated by a delimiter. */
|
/* Creates a single String consisting of a list of strings separated by a delimiter. */
|
||||||
static Result<String> join(const Vector<String>& vec, StringView delim);
|
static Result<String> join(const Vector<String>& vec, StringView delim);
|
||||||
|
|
||||||
/* Creates a single String consisting of a list of strings separated by a delimiter. */
|
|
||||||
static Result<String> join(const Vector<StringView>& vec, StringView delim);
|
|
||||||
|
|
||||||
/* Removes all trailing characters contained in delim. */
|
/* Removes all trailing characters contained in delim. */
|
||||||
void trim(StringView delim);
|
void trim(StringView delim);
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
_e(lseek) _e(mkdir) _e(execve) _e(fork) _e(waitpid) _e(getppid) _e(fcntl) _e(getdents) _e(getuid) _e(geteuid) \
|
_e(lseek) _e(mkdir) _e(execve) _e(fork) _e(waitpid) _e(getppid) _e(fcntl) _e(getdents) _e(getuid) _e(geteuid) \
|
||||||
_e(getgid) _e(getegid) _e(setuid) _e(setgid) _e(seteuid) _e(setegid) _e(fchmodat) _e(fchownat) _e(ioctl) \
|
_e(getgid) _e(getegid) _e(setuid) _e(setgid) _e(seteuid) _e(setegid) _e(fchmodat) _e(fchownat) _e(ioctl) \
|
||||||
_e(fstatat) _e(chdir) _e(getcwd) _e(unlinkat) _e(uname) _e(sethostname) _e(dup2) _e(pipe) _e(mount) \
|
_e(fstatat) _e(chdir) _e(getcwd) _e(unlinkat) _e(uname) _e(sethostname) _e(dup2) _e(pipe) _e(mount) \
|
||||||
_e(umount) _e(pstat) _e(getrusage)
|
_e(umount) _e(pstat)
|
||||||
|
|
||||||
enum Syscalls
|
enum Syscalls
|
||||||
{
|
{
|
||||||
|
@ -181,23 +181,6 @@ Result<String> String::join(const Vector<String>& vec, StringView delim)
|
|||||||
return sb.string();
|
return sb.string();
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<String> String::join(const Vector<StringView>& vec, StringView delim)
|
|
||||||
{
|
|
||||||
if (vec.size() == 0) return String {};
|
|
||||||
if (vec.size() == 1) return from_string_view(vec[0]);
|
|
||||||
|
|
||||||
StringBuilder sb;
|
|
||||||
TRY(sb.add(vec[0]));
|
|
||||||
|
|
||||||
for (usize i = 1; i < vec.size(); i++)
|
|
||||||
{
|
|
||||||
TRY(sb.add(delim));
|
|
||||||
TRY(sb.add(vec[i]));
|
|
||||||
}
|
|
||||||
|
|
||||||
return sb.string();
|
|
||||||
}
|
|
||||||
|
|
||||||
int String::compare(const String* a, const String* b)
|
int String::compare(const String* a, const String* b)
|
||||||
{
|
{
|
||||||
return strcmp(a->chars(), b->chars());
|
return strcmp(a->chars(), b->chars());
|
||||||
|
@ -11,7 +11,6 @@ namespace os
|
|||||||
static Result<pid_t> fork();
|
static Result<pid_t> fork();
|
||||||
|
|
||||||
static Result<void> exec(StringView path, Slice<String> args, bool search_in_path = true);
|
static Result<void> exec(StringView path, Slice<String> args, bool search_in_path = true);
|
||||||
static Result<void> exec(StringView path, Slice<StringView> args, bool search_in_path = true);
|
|
||||||
static Result<void> exec(StringView path, Slice<String> args, Slice<String> env, bool search_in_path = true);
|
static Result<void> exec(StringView path, Slice<String> args, Slice<String> env, bool search_in_path = true);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -24,19 +24,6 @@ namespace os
|
|||||||
return err(errno);
|
return err(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<void> Process::exec(StringView path, Slice<StringView> args, bool search_in_path)
|
|
||||||
{
|
|
||||||
Vector<const char*> argv;
|
|
||||||
for (const auto& arg : args) { TRY(argv.try_append(arg.chars())); }
|
|
||||||
TRY(argv.try_append(nullptr));
|
|
||||||
|
|
||||||
if (search_in_path) execvp(path.chars(), const_cast<char**>(argv.data()));
|
|
||||||
else
|
|
||||||
execv(path.chars(), const_cast<char**>(argv.data()));
|
|
||||||
|
|
||||||
return err(errno);
|
|
||||||
}
|
|
||||||
|
|
||||||
Result<void> Process::exec(StringView path, Slice<String> args, Slice<String> env, bool search_in_path)
|
Result<void> Process::exec(StringView path, Slice<String> args, Slice<String> env, bool search_in_path)
|
||||||
{
|
{
|
||||||
Vector<const char*> argv;
|
Vector<const char*> argv;
|
||||||
|
Loading…
Reference in New Issue
Block a user