mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 00:14:32 -08:00
[kernel] Added the process_kill syscall
Added process_kill, and also cleaned up all the disparate types being used for thread/process exit codes. (Now all int32_t.)
This commit is contained in:
@@ -10,10 +10,11 @@ SYSCALL(0x0b, object_close, j6_handle_t)
|
|||||||
|
|
||||||
SYSCALL(0x10, process_create, j6_handle_t *)
|
SYSCALL(0x10, process_create, j6_handle_t *)
|
||||||
SYSCALL(0x11, process_start, j6_handle_t *, uintptr_t)
|
SYSCALL(0x11, process_start, j6_handle_t *, uintptr_t)
|
||||||
SYSCALL(0x17, process_exit, int64_t)
|
SYSCALL(0x11, process_kill, j6_handle_t)
|
||||||
|
SYSCALL(0x17, process_exit, int32_t)
|
||||||
|
|
||||||
SYSCALL(0x18, thread_create, void *, j6_handle_t *)
|
SYSCALL(0x18, thread_create, void *, j6_handle_t *)
|
||||||
SYSCALL(0x19, thread_exit, int64_t)
|
SYSCALL(0x19, thread_exit, int32_t)
|
||||||
SYSCALL(0x1a, thread_pause, void)
|
SYSCALL(0x1a, thread_pause, void)
|
||||||
SYSCALL(0x1b, thread_sleep, uint64_t)
|
SYSCALL(0x1b, thread_sleep, uint64_t)
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ process::create_kernel_process(page_table *pml4)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
process::exit(unsigned code)
|
process::exit(int32_t code)
|
||||||
{
|
{
|
||||||
// TODO: make this thread-safe
|
// TODO: make this thread-safe
|
||||||
m_state = state::exited;
|
m_state = state::exited;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
/// Terminate this process.
|
/// Terminate this process.
|
||||||
/// \arg code The return code to exit with.
|
/// \arg code The return code to exit with.
|
||||||
void exit(unsigned code);
|
void exit(int32_t code);
|
||||||
|
|
||||||
/// Update internal bookkeeping about threads.
|
/// Update internal bookkeeping about threads.
|
||||||
void update();
|
void update();
|
||||||
@@ -84,7 +84,7 @@ private:
|
|||||||
// This constructor is called by create_kernel_process
|
// This constructor is called by create_kernel_process
|
||||||
process(page_table *kpml4);
|
process(page_table *kpml4);
|
||||||
|
|
||||||
uint32_t m_return_code;
|
int32_t m_return_code;
|
||||||
|
|
||||||
vm_space m_space;
|
vm_space m_space;
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ thread::wake_on_result(kobject *obj, j6_status_t result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
thread::exit(uint32_t code)
|
thread::exit(int32_t code)
|
||||||
{
|
{
|
||||||
m_return_code = code;
|
m_return_code = code;
|
||||||
set_state(state::exited);
|
set_state(state::exited);
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ public:
|
|||||||
|
|
||||||
/// Terminate this thread.
|
/// Terminate this thread.
|
||||||
/// \arg code The return code to exit with.
|
/// \arg code The return code to exit with.
|
||||||
void exit(unsigned code);
|
void exit(int32_t code);
|
||||||
|
|
||||||
/// Add a stack header that returns to the given address in kernel space.
|
/// Add a stack header that returns to the given address in kernel space.
|
||||||
/// \arg rip The address to return to, must be kernel space
|
/// \arg rip The address to return to, must be kernel space
|
||||||
@@ -173,7 +173,7 @@ private:
|
|||||||
wait_type m_wait_type;
|
wait_type m_wait_type;
|
||||||
// There should be 1 byte of padding here
|
// There should be 1 byte of padding here
|
||||||
|
|
||||||
uint32_t m_return_code;
|
int32_t m_return_code;
|
||||||
|
|
||||||
uint64_t m_wait_data;
|
uint64_t m_wait_data;
|
||||||
j6_status_t m_wait_result;
|
j6_status_t m_wait_result;
|
||||||
|
|||||||
@@ -22,7 +22,20 @@ process_start(j6_handle_t *handle, uintptr_t entrypoint)
|
|||||||
}
|
}
|
||||||
|
|
||||||
j6_status_t
|
j6_status_t
|
||||||
process_exit(int64_t status)
|
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::syscall, "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();
|
process &p = process::current();
|
||||||
log::debug(logs::syscall, "Process %llx exiting with code %d", p.koid(), status);
|
log::debug(logs::syscall, "Process %llx exiting with code %d", p.koid(), status);
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ thread_create(void *rip, j6_handle_t *handle)
|
|||||||
}
|
}
|
||||||
|
|
||||||
j6_status_t
|
j6_status_t
|
||||||
thread_exit(int64_t status)
|
thread_exit(int32_t status)
|
||||||
{
|
{
|
||||||
thread &th = thread::current();
|
thread &th = thread::current();
|
||||||
log::debug(logs::syscall, "Thread %llx exiting with code %d", th.koid(), status);
|
log::debug(logs::syscall, "Thread %llx exiting with code %d", th.koid(), status);
|
||||||
|
|||||||
Reference in New Issue
Block a user