24#include <aquila/errno.h>
110#define STOP_SIGNALS ((1UL << SIGSTOP) | (1UL << SIGTSTP) | (1UL << SIGTTIN) | (1UL << SIGTTOU))
140 if (signal < 0 || signal >
SIG_MAX)
156 }
else if (signal == SIGCONT || signal == SIGKILL) {
162 if (signal == SIGCONT) {
273 int sig = (
ready & (1UL << SIGKILL)) ? SIGKILL : __builtin_ctzl(
ready);
342 if (signal < 0 || signal >
SIG_MAX)
367 return found ? 0 : -ESRCH;
383 return found ? 0 : -ESRCH;
void arch_sleep(void)
Puts the current thread to sleep.
#define PROC_EXIT(info, code)
int pgrp_orphaned(struct pgroup *pgrp, struct proc *gone)
Says whether a process group is orphaned (POSIX): none of its members has a parent in another group o...
struct proc * proc_pid_find(pid_t pid)
Finds a process by its ID.
void proc_kill(struct proc *proc)
Ends a process: its threads end, its descriptors are closed, its memory is freed, its children go to ...
void sched_thread_kick(struct thread *thread)
Makes a thread that runs on another CPU enter the kernel now, rather than at its next tick: a signal ...
int signal_interrupts(struct thread *thread)
Says whether a thread has a signal to take, which ends a sleep that a signal may end.
int signal_proc_send(struct proc *proc, int signal)
Sends a signal to a process.
void signal_exit(int sig)
Ends the current process because of a signal.
int signal_stops(struct proc *proc, int sig)
Says whether delivering a signal to a process would stop it: the signal isn't caught,...
void signal_stop(int sig)
Stops the current process, until SIGCONT or SIGKILL.
int signal_send(int pid, int sig)
Sends a signal as kill() does.
void signal_force(struct proc *proc, int signal)
Sends a signal that can't be blocked or ignored, such as the SIGSEGV of a fault: if the process block...
int signal_take(void)
Takes the current process's pending signals, on the way back to user mode: ignored ones are dropped,...
int sig_default_action[SIG_MAX+1]
int signal_pgrp_send(struct pgroup *pg, int signal)
Sends a signal to every process of a process group.
void signal_action_set(struct proc *proc, int sig)
Discards a pending signal that sigaction() just made ignored.
An installed handler, on its interrupt's list.
A process group: the processes of a job.
struct queue * procs
its processes
struct waitq stop_queue
its stopped threads sleep here
pid_t pid
the process's ID
struct proc * parent
its parent
struct aquila_sigaction sigaction[SIG_MAX+1]
its signal actions
struct waitq wait_queue
a parent waiting for a child (waitpid()) sleeps here
int stopped
the signal that stopped it, or 0; and what waitpid() has to report (WAIT_*)
int running
whether it's running
struct queue threads
its threads
sigset_t sig_pending
its pending signals, a bit (1 << sig) each: a signal sent again while it's pending is delivered once ...
struct pgroup * pgrp
its process group, and its node on the group's list
sigset_t sigmask
its blocked signals, a bit (1 << sig) each
struct proc * owner
its process
static int signal_ignored(struct proc *proc, int sig)
Returns whether delivering sig would do nothing: the process ignores it, or its default action is to ...
static int signal_to(struct proc *proc, int signal)
Sends a signal to a process: makes it pending, and if the process doesn't block it,...
static void signal_notify_parent(struct proc *proc)
Tells a process's parent that it stopped or continued: its wait() wakes up, and it gets SIGCHLD unles...
static int is_stop_signal(int sig)
Returns whether sig is one of the stop signals.
void thread_wakeup(struct thread *thread)
Wakes up one thread, if it is sleeping on a wait queue.
void waitq_wakeup(struct waitq *waitq)
Wakes up every thread sleeping on a wait queue, and every thread polling it.
void waitq_sleep_unint(struct waitq *waitq)
Puts the current thread to sleep on a wait queue until it is woken up, whatever signals come meanwhil...