miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
signal.c File Reference
#include <miniOS/io.h>
#include <miniOS/signal.h>
#include <miniOS/sched/sched.h>
#include <miniOS/mm/vmm.h>
Include dependency graph for signal.c:

Functions

void proc_close_all_sockets (struct thread *t)
static int signal_default_terminates (int sig)
void signal_dispatch (void)
void ring3_invoke_handler (int sig, sighandler_t handler)

Function Documentation

◆ proc_close_all_sockets()

void proc_close_all_sockets ( struct thread * t)
extern

proc_close_all_sockets() - Close all open socket file descriptors for a thread. @t: Thread whose sockets should be closed.

Called directly from sched_exit_current() on every exit path (normal SYS_exit, page faults, signals). signal_dispatch() may also call it before sched_exit_current(); the second call is harmless because freed fds have in_use=0 and are silently skipped.

net_sock_free() handles PCB teardown internally (raw_remove/udp_remove/ tcp_abort + null pcb before in_use=0).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ring3_invoke_handler()

void ring3_invoke_handler ( int sig,
sighandler_t handler )

ring3_invoke_handler() - Set up user stack to invoke a signal handler. @sig: Signal number passed as first argument to handler (RDI per SysV ABI). @handler: User-mode function pointer to invoke.

Modifies the current thread's saved_user_rip to point to @handler and adjusts saved_user_rsp to push the signal number onto the user stack. SYSRET then jumps directly into the handler. Full trampoline (return path via SYS_sigreturn).

Here is the call graph for this function:
Here is the caller graph for this function:

◆ signal_default_terminates()

int signal_default_terminates ( int sig)
static
Here is the caller graph for this function:

◆ signal_dispatch()

void signal_dispatch ( void )

signal_dispatch() - Deliver all pending signals before returning to userspace.

Called from syscall.asm immediately before SYSRET. Scans the current thread's pending_signals bitmask (bits 1-31). For SIGKILL and SIGTERM calls sched_exit_current(128 + signum). For other signals invokes the registered handler via ring3_invoke_handler() if a non-default handler is registered, otherwise clears the pending bit and continues.

Context: Called with interrupts disabled (CLI before SYSRET path). Does not return if SIGKILL or SIGTERM is pending.

Here is the call graph for this function: