CeDOS - Commit c834992d

syscall: Add process_kill syscall and shell tool Adding a syscall and a shell tool to kill a process that is running asynchronously.
Celina Sophie Kalus
Wed, 06 Dec 2023 00:48:31 +0100
4 files changed, 21 insertions(+), 1 deletions(-)
M kernel/syscall.ckernel/syscall.c

@@ -24,7 +24,8 @@ file_dir_next,

file_lseek, file_tell, time_get_ticks, - mem_usage + mem_usage, + sched_kill }; extern void syscall_interrupt(void);
M libcedos/cedos.clibcedos/cedos.c

@@ -95,3 +95,8 @@ volatile int res = 0;

interrupt(0x30, res, 13, 0, 0, 0); return res; } + +void process_kill(int pid) { + volatile uint32_t res = 0; + interrupt(0x30, res, 14, pid, 0, 0); +}
M libcedos/cedos.hlibcedos/cedos.h

@@ -11,6 +11,7 @@ int get_pid();

int process_spawn(const char *fname, const char *args); int process_spawn_pipe(const char *fname, const char *args, int stdin, int stdout); void process_wait(int pid); +void process_kill(int pid); void graphics_set_mode(int mode);
A shell/kill.c

@@ -0,0 +1,13 @@

+#include "cedos.h" + +#include <stdint.h> +#include "stdlib.h" +#include "string.h" + +#include "cedos.h" + +void main(char *args) { + int pid = atoi(args); + + process_kill(pid); +}