signals - Unix Signals (CSE 422S) Dante Cannarozzi...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
Dante Cannarozzi Washington University djc2@cse.wustl.edu www.cse.wustl.edu/~djc2 Unix Signals (CSE 422S)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 -Ken Wong, Sep 2008 The Signal Concept Generating Signals » Command Line : kill –9 8371 Unconditionally kill process 8371 Equivalent to ±kill -KILL 8371’ (send SIGKILL to process 8371) » Keyboard : ctrl-c Interactive interrupt key Equivalent to sending SIGINT signal to shell (and its proc group) » Program : if (kill(8371, SIGTERM) == -1) . . . Signals are asynchronous event notifications » Like software interrupt but sent by OS to process Every signal has a name and a positive integer » See signal(7) » <signal.h> : Mapping between names and numbers See /usr/include/bits/signum.h (e.g., SIGKILL 9) 9: actual signal number 9: actual signal number SIGKILL: mnemonic SIGKILL: mnemonic
Background image of page 2
3 -Ken Wong, Sep 2008 Some Signals and Default Actions Abnormal Termination » SIGINT : User presses interrupt (usually ctrl-c ) key » SIGPIPE : Process writes to a pipe after reader has quit » SIGALRM : Alarm clock expires » SIGTERM : Terminate (kill) process » SIGKILL : Terminate (kill) process (Can’t be caught/ignored) Stop Process » SIGTSTP : User presses suspend ( ctl-z ) key » SIGSTOP : Stop process (Can’t be caught/ignored) SIGCONT continues process » SIGTTIN : Background process attempts to read from controlling terminal Implementation Dependent » SIGCHLD : Child process terminates » SIGQUIT : User presses quit ( ctrl-| ) key produces core dump See signal(7) for list of signals and their values
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 -Ken Wong, Sep 2008 Project A Keyboard-Generated Signals Example: Effect of ctrl-c on user processes » Terminate all foreground (FG) processes all processes in the FG pipeline » Return control to command line prompt » Should NOT terminate background processes or the interactive shell xssh Unix handling of ctrl-c » Send SIGINT to all processes in FG process group Strategy » Put each pipeline in a process group ls –l | grep Oct > xxx & ls –l | grep Oct > xxx & find /usr –mtime -60 | grep ‘*.c’ find /usr –mtime -60 | grep ‘*.c’ ^-c ^-c ctrl-c ctrl-c
Background image of page 4
5 -Ken Wong, Sep 2008 Terminology A signal is generated by certain events » Hardware exception (divide by 0) » A software condition becomes true ( alarm timer expires) » A terminal generates a signal ( kill command) » The kill (2) system call & OS Kernel sets a flag in the process table for the signal Signal is delivered to a process when signal action is taken A signal is pending if it is generated, but not delivered A process can: » Block the delivery of a signal or » Ignore the signal (throw it away) If a signal is generated more than once while blocked, the user can have: » One delivery (typical case) or » Many deliveries (i.e., queue the signals) The process signal mask indicates the blocked signals
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 -Ken Wong, Sep 2008 Concepts Signal Mask » Indicates the set of signals which should be blocked Blocking means hold for later delivery (different from ignore) Ignore means throw signal away » Type is sigset_t » Manipulated by five functions sigaddset ,
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This document was uploaded on 11/13/2009.

Page1 / 32

signals - Unix Signals (CSE 422S) Dante Cannarozzi...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online