MentOS
0.8.0
The Mentoring Operating System
|
Signals definition. More...
Macros | |
#define | __DEBUG_HEADER__ "[SIGNAL]" |
Change header. | |
#define | __DEBUG_LEVEL__ LOGLEVEL_NOTICE |
Set log level. | |
#define | GET_EXIT_STATUS(status) (((status) & 0x00FF) << 8) |
Extracts the exit status. | |
Functions | |
static void | __copy_sigaction (sigaction_t *to, const sigaction_t *from) |
Copies the sigaction. More... | |
static void | __copy_sigset (sigset_t *to, const sigset_t *from) |
Copies a signal set. More... | |
static void | __copy_siginfo (siginfo_t *to, const siginfo_t *from) |
Copies a signal information structure. More... | |
static void | __clear_siginfo (siginfo_t *info) |
Clears the memory of a signal information structure. More... | |
static void | __lock_task_sighand (struct task_struct *t) |
Locks the signal handling of a given task. More... | |
static void | __unlock_task_sighand (struct task_struct *t) |
Unlocks the signal handling of a given task. More... | |
static sighandler_t | __get_handler (struct task_struct *t, int sig) |
Returns the handler for a given signal, for a given task. More... | |
static int | __sig_is_ignored (struct task_struct *t, int sig) |
Checks if the given signal is ignored. More... | |
static sigqueue_t * | __sigqueue_alloc (struct task_struct *t, int sig, gfp_t flags) |
Allocate a new signal queue record. More... | |
static void | __sigqueue_dealloc (sigqueue_t *sigqueue) |
Freest the memory of a signal queue. More... | |
static int | __send_signal (int sig, siginfo_t *info, struct task_struct *t) |
Sends a signal. More... | |
static int | __next_signal (sigpending_t *pending, sigset_t *mask) |
Gets the next signal that abides by the given mask. More... | |
static void | __collect_signal (int sig, sigpending_t *list, siginfo_t *info) |
Collects the signals from the list. More... | |
static int | __dequeue_signal (sigpending_t *pending, sigset_t *mask, siginfo_t *info) |
Dequeues a signal that abides by the mask. More... | |
static int | __handle_signal (int signr, siginfo_t *info, sigaction_t *ka, struct pt_regs *regs) |
Handels the signals for the current process. More... | |
long | sys_sigreturn (struct pt_regs *f) |
Handle the return from a signal handler. More... | |
static int | __notify_parent (struct task_struct *current, int signr) |
Send signal to parent. More... | |
static void | __rm_from_queue (sigset_t *mask, sigpending_t *q) |
Removes from the pending signal queue q the pending signals corresponding to the bit mask mask. More... | |
static void | __do_signal_stop (struct task_struct *current, struct pt_regs *f, int signr) |
We do not consider group stopping because for now we don't have thread groups. More... | |
int | do_signal (struct pt_regs *f) |
Handles the signals of the current process. More... | |
int | signals_init (void) |
Initialize the signals. More... | |
void | handle_stop_signal (int sig, siginfo_t *info, struct task_struct *p) |
Checks for some types of signals that might nullify other pending signals for the destination thread group. More... | |
int | __send_sig_info (int sig, siginfo_t *info, struct task_struct *p) |
Send siginfo to target process. More... | |
int | sys_kill (pid_t pid, int sig) |
Send signal to one specific process. More... | |
sighandler_t | sys_signal (int signum, sighandler_t handler, uint32_t sigreturn_addr) |
Sets the disposition of the signal signum to handler. More... | |
int | sys_sigaction (int signum, const sigaction_t *act, sigaction_t *oldact, uint32_t sigreturn_addr) |
Examine and change a signal action. More... | |
int | sys_sigprocmask (int how, const sigset_t *set, sigset_t *oldset) |
Examine and change blocked signals. More... | |
int | sys_sigpending (sigset_t *set) |
Provides a snapshot of pending signals. More... | |
const char * | strsignal (int sig) |
Returns the string describing the given signal. More... | |
int | sigemptyset (sigset_t *set) |
Prepare an empty set. More... | |
int | sigfillset (sigset_t *set) |
Prepare a full set. More... | |
int | sigaddset (sigset_t *set, int signum) |
Adds the given signal to the correct set. More... | |
int | sigdelset (sigset_t *set, int signum) |
Removes the given signal to the correct set. More... | |
int | sigismember (sigset_t *set, int signum) |
Checks if the given signal is part of the set. More... | |
Variables | |
static kmem_cache_t * | sigqueue_cachep |
SLAB caches for signal bits. | |
static struct wait_queue_head_t | stopped_queue |
Contains all stopped process waiting for a continue signal. | |
static const char * | sys_siglist [] |
The list of signal names. | |
Signals definition.
|
inlinestatic |
Clears the memory of a signal information structure.
info | the signal information structure. |
|
inlinestatic |
Collects the signals from the list.
sig | the signal. |
list | the list of pending signals. |
info | the where we store the signal information. |
|
inlinestatic |
Copies the sigaction.
to | the target. |
from | the source. |
Copies a signal information structure.
to | the target. |
from | the source. |
Copies a signal set.
to | the target. |
from | the source. |
|
inlinestatic |
Dequeues a signal that abides by the mask.
pending | the list of pending signals. |
mask | the mask used to select the signals. |
info | the signal information, where we store the information of the dequeued signal. |
|
static |
We do not consider group stopping because for now we don't have thread groups.
current | the current process. |
f | the stack frame. |
signr | signal number. |
|
static |
Returns the handler for a given signal, for a given task.
t | the task. |
sig | the signal index. |
|
inlinestatic |
Handels the signals for the current process.
signr | the signal number. |
info | the signal information. |
ka | the action associated with the signal. |
regs | the current registers. |
|
inlinestatic |
Locks the signal handling of a given task.
t | the task. |
|
inlinestatic |
Gets the next signal that abides by the given mask.
pending | the list of pending signals. |
mask | the mask we are checking against. |
|
static |
Send signal to parent.
current | the current task. |
signr | the signal number. |
|
static |
Removes from the pending signal queue q the pending signals corresponding to the bit mask mask.
mask | the mask we use to guide signals removal. |
q | pensing signals. |
int __send_sig_info | ( | int | sig, |
siginfo_t * | info, | ||
struct task_struct * | p | ||
) |
Send siginfo to target process.
sig | Signal number |
info | siginfo struct of the signal to be sent |
p | Target process where the signal will be sent |
|
static |
Sends a signal.
sig | Signal to be sent. |
info | The signal info |
t | The process to which we send the signal. |
|
static |
Checks if the given signal is ignored.
t | the task. |
sig | the signal to check. |
|
inlinestatic |
Allocate a new signal queue record.
t | The task to which the signal belongs. |
sig | The signal to set. |
flags | Flags identifying from where we are going to take the memory. |
|
inlinestatic |
Freest the memory of a signal queue.
sigqueue | the signal queue to free. |
|
inlinestatic |
Unlocks the signal handling of a given task.
t | the task. |
int do_signal | ( | struct pt_regs * | f | ) |
Handles the signals of the current process.
f | The address of the stack area where the User Mode register contents of the current process are saved. |
regs
have been modified to handle it (e.g., eip is now poiting at the handler). void handle_stop_signal | ( | int | sig, |
siginfo_t * | info, | ||
struct task_struct * | p | ||
) |
Checks for some types of signals that might nullify other pending signals for the destination thread group.
sig | Signal number |
info | siginfo struct of the signal |
p | Target process of the signal |
int sigaddset | ( | sigset_t * | set, |
int | signum | ||
) |
Adds the given signal to the correct set.
set | The set to manipulate. |
signum | The signalt to handle. |
int sigdelset | ( | sigset_t * | set, |
int | signum | ||
) |
Removes the given signal to the correct set.
set | The set to manipulate. |
signum | The signalt to handle. |
int sigemptyset | ( | sigset_t * | set | ) |
Prepare an empty set.
set | The set to manipulate. |
int sigfillset | ( | sigset_t * | set | ) |
Prepare a full set.
set | The set to manipulate. |
int sigismember | ( | sigset_t * | set, |
int | signum | ||
) |
Checks if the given signal is part of the set.
set | The set to manipulate. |
signum | The signalt to handle. |
int signals_init | ( | void | ) |
Initialize the signals.
const char* strsignal | ( | int | sig | ) |
Returns the string describing the given signal.
sig | The signal to inquire. |
int sys_kill | ( | pid_t | pid, |
int | sig | ||
) |
Send signal to one specific process.
pid | The PID of the process. |
sig | The signal to be sent. |
int sys_sigaction | ( | int | signum, |
const sigaction_t * | act, | ||
sigaction_t * | oldact, | ||
uint32_t | sigreturn_addr | ||
) |
Examine and change a signal action.
signum | Specifies the signal and can be any valid signal except SIGKILL and SIGSTOP. |
act | If non-NULL, the new action for signal signum is installed from act. |
oldact | If non-NULL, the previous action is saved in oldact. |
sigreturn_addr | The address of the sigreturn function. |
sighandler_t sys_signal | ( | int | signum, |
sighandler_t | handler, | ||
uint32_t | sigreturn_addr | ||
) |
Sets the disposition of the signal signum to handler.
signum | The signal number. |
handler | The handler for the signal. |
sigreturn_addr | The address of the sigreturn function. |
int sys_sigpending | ( | sigset_t * | set | ) |
Provides a snapshot of pending signals.
set | where the set of pending signals is returned. |
Examine and change blocked signals.
how | Determines the behavior of the call. |
set | The set of signals to manage by the function. |
oldset | If non-NULL, the previous value of the signal mask is stored here. |
If set is NULL, then the signal mask is unchanged (i.e., how is ignored), but the current value of the signal mask is nevertheless returned in oldset (if it is not NULL).
long sys_sigreturn | ( | struct pt_regs * | f | ) |
Handle the return from a signal handler.
f | The stack frame when returning from a signal handler. |