Sigsetops APIs - Signal Mask (3) * int sigemptyset (sigset_t* sigmask) Clears all signal flags in the sigmask argument. old_mask = NULL, no previous signal mask will be return. SIG_UNBLOCK: Removes the signals specified in the new_mask argument from the calling process signal mask * old_mask: Address of a sigset_t variable that will be assigned the calling processing’s original signal mask. SIG_BLOCK: Adds the signals specified in the new_mask argument to the calling process signal mask. * cmd: specifies how the new_mask value is to be used: - SIG_SETMASK: Overrides the calling process signal mask with the value specified in the new_mask argument. new_mask = NULL, current process signal mask unaltered. * Include: * Summary: int sigprocmask ( int cmd, cost sigset_t *new_mask, sigset_t *old_mask) * Return: Success: 0 Failure: -1 Sets errno: YesĪrguments of sigprocmask API - Signal Mask (2) * new_mask: defines a set of signals to be set or reset in a calling process signal mask. Sigprocmask API - Signal Mask (1) * Function A process can query or set its signal mask via the sigprocmask API. * Catch the Signal When a process catches a signal, except SIGSTOP and SIGKILL, it invokes a special signal handing routine. * Ignore the signal A process can do ignoring with all signal but two special signals: SIGSTOP and SIGKILL. Three Courses of Action Process that receives a signal can take one of three action: * Perform the system-specified default for the signal - notify the parent process that it is terminating - generate a core file (a file containing the current memory image of the process) - terminate. * User - Pressing keyboard sequences that generate a quit, interrupt or stop signal. * Other Processes - A child process notifying its parent process that it has terminated. * Kernel - Notifying the process that an I/O device for which it has been waiting is available. Sources for Generating Signals * Hardware - A process attempts to access addresses outside its own address space. Signal can be sent by one process to another process (or to itself) or by the kernel to a process. The process does not know ahead of time exactly when a signal will occur. * Features of Signal - Signal usually occur asynchronously. Signals are sometimes called “software interrupts”. Signaling Processes * Signal A signal is a notification to a process that an event has occurred. * SIGTTOUT: Stop a background process when it tries to write to its controlling terminal. * SIGTSTP: Stop a process execution by the control_Z keys. * SIGTTIN: Stop a background process when it tries to read from from its controlling terminal. * SIGCONT: Resume execution of a stopped process. * SIGCHLD: Sent to a parent process when its child process has terminated. * SIGUSR2: Reserved to be defined by user. * SIGUSR1: Reserved to be defined by user. POSIX-Defined Signals (2) * SIGTERM: process termination. generated by de-referencing a NULL pointer. * SIGILL: Execution of an illegal machine instruction. * SIGFPE: Illegal mathematical operation. POSIX-Defined Signals (1) * SIGALRM: Alarm timer time-out. UNIX Signals * POSIX-Defined Signals * Signaling Processes * Signal Mask * sigaction * kill and sigaction * alarm * Interval Timers * POSIX.1b Timers * timer Class
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |