diff --git a/base/usr/include/kernel/system.h b/base/usr/include/kernel/system.h index dc278b6b..7ac35659 100644 --- a/base/usr/include/kernel/system.h +++ b/base/usr/include/kernel/system.h @@ -223,7 +223,7 @@ typedef struct { extern void handle_signal(process_t *, signal_t *); -extern int send_signal(pid_t process, uint32_t signal); +extern int send_signal(pid_t process, uint32_t signal, int force); #define USER_STACK_BOTTOM 0xAFF00000 #define USER_STACK_TOP 0xB0000000 diff --git a/kernel/fs/pipe.c b/kernel/fs/pipe.c index f645c6ed..6a35d37d 100644 --- a/kernel/fs/pipe.c +++ b/kernel/fs/pipe.c @@ -102,7 +102,7 @@ uint32_t read_pipe(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *buf if (pipe->dead) { debug_print(WARNING, "Pipe is dead?"); - send_signal(getpid(), SIGPIPE); + send_signal(getpid(), SIGPIPE, 1); return 0; } @@ -146,7 +146,7 @@ uint32_t write_pipe(fs_node_t *node, uint32_t offset, uint32_t size, uint8_t *bu if (pipe->dead) { debug_print(WARNING, "Pipe is dead?"); - send_signal(getpid(), SIGPIPE); + send_signal(getpid(), SIGPIPE, 1); return 0; } diff --git a/kernel/fs/tty.c b/kernel/fs/tty.c index 180f742c..b1968dae 100644 --- a/kernel/fs/tty.c +++ b/kernel/fs/tty.c @@ -114,7 +114,7 @@ static void input_process(pty_t * pty, uint8_t c) { } clear_input_buffer(pty); if (pty->fg_proc) { - send_signal(pty->fg_proc, SIGINT); + send_signal(pty->fg_proc, SIGINT, 1); } return; } @@ -126,7 +126,7 @@ static void input_process(pty_t * pty, uint8_t c) { } clear_input_buffer(pty); if (pty->fg_proc) { - send_signal(pty->fg_proc, SIGQUIT); + send_signal(pty->fg_proc, SIGQUIT, 1); } return; } diff --git a/kernel/fs/unixpipe.c b/kernel/fs/unixpipe.c index 28e70cbb..ba3a4b8f 100644 --- a/kernel/fs/unixpipe.c +++ b/kernel/fs/unixpipe.c @@ -53,7 +53,7 @@ static uint32_t write_unixpipe(fs_node_t * node, uint32_t offset, uint32_t size, while (written < size) { if (self->read_closed) { /* SIGPIPE to current process */ - send_signal(getpid(), SIGPIPE); + send_signal(getpid(), SIGPIPE, 1); return written; } diff --git a/kernel/mem/mem.c b/kernel/mem/mem.c index bd782f4a..2386c4a4 100644 --- a/kernel/mem/mem.c +++ b/kernel/mem/mem.c @@ -522,7 +522,7 @@ page_fault( #endif - send_signal(current_process->id, SIGSEGV); + send_signal(current_process->id, SIGSEGV, 1); } /* diff --git a/kernel/sys/panic.c b/kernel/sys/panic.c index fccc31d7..05cf1f07 100644 --- a/kernel/sys/panic.c +++ b/kernel/sys/panic.c @@ -26,7 +26,7 @@ void halt_and_catch_fire(char * error_message, const char * file, int line, stru debug_print(ERROR, "User ESP: 0x%x", regs->useresp); debug_print(ERROR, "eip=0x%x", regs->eip); } - send_signal(current_process->id, SIGILL); + send_signal(current_process->id, SIGILL, 1); } char * probable_function_name(uintptr_t ip, uintptr_t * out_addr) { diff --git a/kernel/sys/signal.c b/kernel/sys/signal.c index 40065d5e..fdca1a84 100644 --- a/kernel/sys/signal.c +++ b/kernel/sys/signal.c @@ -183,7 +183,7 @@ void fix_signal_stacks(void) { } } -int send_signal(pid_t process, uint32_t signal) { +int send_signal(pid_t process, uint32_t signal, int force_root) { process_t * receiver = process_from_pid(process); if (!receiver) { @@ -191,7 +191,7 @@ int send_signal(pid_t process, uint32_t signal) { return 1; } - if (receiver->user != current_process->user && current_process->user != USER_ROOT_UID) { + if (!force_root && receiver->user != current_process->user && current_process->user != USER_ROOT_UID) { /* No way in hell. */ return 1; } diff --git a/kernel/sys/syscall.c b/kernel/sys/syscall.c index 2d588581..84d73586 100644 --- a/kernel/sys/syscall.c +++ b/kernel/sys/syscall.c @@ -776,7 +776,7 @@ static int sys_shm_release(char * path) { } static int sys_kill(pid_t process, uint32_t signal) { - return send_signal(process, signal); + return send_signal(process, signal, 0); } static int sys_gettimeofday(struct timeval * tv, void * tz) { diff --git a/modules/lfbvideo.c b/modules/lfbvideo.c index 42cd4a7e..4ccf7a53 100644 --- a/modules/lfbvideo.c +++ b/modules/lfbvideo.c @@ -47,7 +47,7 @@ void lfb_set_resolution(uint16_t x, uint16_t y) { if (lfb_resolution_impl) { lfb_resolution_impl(x,y); if (display_change_recipient) { - send_signal(display_change_recipient, SIGWINEVENT); + send_signal(display_change_recipient, SIGWINEVENT, 1); debug_print(WARNING, "Telling %d to SIGWINEVENT", display_change_recipient); } }