Files
jsix_import/src/kernel/syscalls/process.cpp
Justin C. Miller cd9b85b555 [util] Replace kutil with util
Now that kutil has no kernel-specific code in it anymore, it can
actually be linked to by anything, so I'm renaming it 'util'.

Also, I've tried to unify the way that the system libraries from
src/libraries are #included using <> instead of "".

Other small change: util::bip_buffer got a spinlock to guard against
state corruption.
2022-01-03 00:03:29 -08:00

60 lines
1.4 KiB
C++

#include <j6/errors.h>
#include <j6/types.h>
#include "log.h"
#include "objects/process.h"
#include "syscalls/helpers.h"
namespace syscalls {
j6_status_t
process_create(j6_handle_t *handle)
{
process *child = construct_handle<process>(handle);
log::debug(logs::task, "Process %llx created", child->koid());
return j6_status_ok;
}
j6_status_t
process_start(j6_handle_t handle, uintptr_t entrypoint, j6_handle_t * handles, size_t handles_count)
{
process &p = process::current();
process *c = get_handle<process>(handle);
if (handles_count && !handles)
return j6_err_invalid_arg;
for (size_t i = 0; i < handles_count; ++i) {
kobject *o = p.lookup_handle(handles[i]);
if (o) c->add_handle(o);
}
return j6_err_nyi;
}
j6_status_t
process_kill(j6_handle_t handle)
{
process &p = process::current();
process *c = get_handle<process>(handle);
if (!c) return j6_err_invalid_arg;
log::debug(logs::task, "Process %llx killed by process %llx", c->koid(), p.koid());
c->exit(-1u);
return j6_status_ok;
}
j6_status_t
process_exit(int32_t status)
{
process &p = process::current();
log::debug(logs::task, "Process %llx exiting with code %d", p.koid(), status);
p.exit(status);
log::error(logs::task, "returned to exit syscall");
return j6_err_unexpected;
}
} // namespace syscalls