unix system programming n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
UNIX System Programming PowerPoint Presentation
Download Presentation
UNIX System Programming

Loading in 2 Seconds...

play fullscreen
1 / 11

UNIX System Programming - PowerPoint PPT Presentation


  • 91 Views
  • Uploaded on

UNIX System Programming. Signals: Wrap-up. Summary. See section 7.4 of Hoover text signal() kill() Lots of “tricky stuff” that you can read about at in the prior signals-UNIX notes or online. continued. Signals. A “low-bandwidth” form of communication between processes:

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'UNIX System Programming' - yosefu


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
unix system programming

UNIX System Programming

Signals: Wrap-up

summary
Summary
  • See section 7.4 of Hoover text
  • signal()
  • kill()
  • Lots of “tricky stuff” that you can read about at in the prior signals-UNIX notes or online.

continued

signals
Signals

A “low-bandwidth” form of communication between processes:

  • typically 30-40 signal types
  • Receiving process may handle or ignore
  • “signal handler” is a function that executes when a signal is received
    • Current process is interrupted
    • Signal is handled
    • Current process resumes
signal handlers
Signal handlers
  • Each process has a default signal handler for each signal
    • default typically terminates the process
  • signal() – installs a signal handler, or tells process to ignore the signal
    • signal(SIGFPE, some-function); where
        • void some-function(int)
    • signal(SIGINT, SIG_IGN);

UNIX System Programming: Signals Maria Hybinette

common signals
Common Signals

UNIX System Programming: Signals Maria Hybinette

common signals continued
Common Signals, continued

UNIX System Programming: Signals Maria Hybinette

generating signals
Generating signals
  • By users, OS, or other processes
  • User at the keyboard:
    • Ctrl-C Pressing this key causes the system to send an INT signal (SIGINT) to the running process. By default, this signal causes the process to immediately terminate.
    • Ctrl-Z Pressing this key causes the system to send a TSTP signal (SIGTSTP) to the running process. By default, this signal causes the process to suspend execution.
    • Ctrl-\ Pressing this key causes the system to send a ABRT signal (SIGABRT) to the running process. By default, this signal causes the process to immediately terminate.

UNIX System Programming: Signals Maria Hybinette

generating signals1
Generating signals
  • User from the command line:
    • kill -INT 5342
    • Kill –USR1 20166
  • From a process:
    • kill(pid, SIGSTOP)

UNIX System Programming: Signals Maria Hybinette

the reset problem
The “Reset” Problem
  • The Traditional System-V Signal Environment
  • inherited its signal-handling environment from V7 research UNIX.
  • has three major limitations:
    • Recursive signal handling is always allowed.
    • Signal handlers are reset to SIG_DFL prior to being called.
    • System calls interrupt when a signal is delivered.
  • These limitations cause "unreliable" signal behavior: Since signals can be delivered recursively and the signal handler must manually reset the signal handler from SIG_DFL, there is a window during which the default signal handler can be called if another signal of the same type arrives. In many cases the default action is to ignore the signal, causing the signal to be lost. In the worst case the default action is to terminate the process.

UNIX System Programming: Signals Maria Hybinette

the fix
“The fix”
  • The BSD 4.X Signal Environment
  • BSD developers modified the signal-handling semantics somewhat:
    • Signals are blocked for the duration of a signal handler (i.e. recursive signals are not normally allowed).
    • A "signal mask" can be set to block most signals during critical regions.
    • Signal handlers normally remain installed during and after signal delivery.
    • A separate signal handler stack can be used if desired.
    • Most system calls are restarted following delivery of a signal.

UNIX System Programming: Signals Maria Hybinette

more details
More details …
  • http://www.tutorialized.com/view/tutorial/Unix-Signals-Programming/42401
  • http://web.eecs.utk.edu/~huangj/cs360/360/notes/Setjmp/lecture.html
  • http://www.cs.ucsb.edu/~almeroth/classes/W99.276/assignment1/signals.html

UNIX System Programming: Signals Maria Hybinette