Lec14-IPC Unix Case Study-Signals

Lec14-IPC Unix Case Study-Signals - Reference Introduction...

Info icon This preview shows pages 1–8. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Reference Reference “Introduction To Unix Signals Programming” Man page – sigprocmask, alarm “Understanding the Linux Kernel” (Oreilly)
Image of page 1

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

View Full Document Right Arrow Icon
2 Signal: An IPC Mechanism Signal: An IPC Mechanism With pipes we communicated data With signal, we can communicate control command The only information is: The number identifying the signal Interrupts a process and forces it to handle the event immediately kill –l can be used to view all the signals supported by your system
Image of page 2
3 Sending signals to process Sending signals to process From keyboard Ctrl-C, Ctrl-Z etc From the command line kill -<signal> <PID> fg Using the kill() system call Also used by the kill and fg command #include <signal.h> /* signal name macros, and the kill() prototype */ /* first, find my own process ID */ pid_t my_pid = getpid(); /* now that i got my PID, send myself the STOP signal. */ kill(my_pid, SIGSTOP);
Image of page 3

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

View Full Document Right Arrow Icon
4 Actions Performed upon Actions Performed upon Receiving a Signal Receiving a Signal There are three ways in which a process can respond to a signal: 1. Explicitly ignore the signal. 2. Execute the default action associated with the signal. 3. Catch the signal by invoking a corresponding signal-handler function.
Image of page 4
5 Signal Handler Signal Handler Corresponding to each signal is a signal handler Called when a process receives a signal The function is called “asynchronously” When the signal handler returns the process continues, as if it was never interrupted Signal are different from interrupts as: Interrupts are sent to OS by H/W Signals are sent to a process by the OS, or by other processes Note that signals have nothing to do with software interrupts
Image of page 5

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

View Full Document Right Arrow Icon
6 Catching a Signal Catching a Signal
Image of page 6
7 The The signal() signal() System Call System Call Used to set signal handler for a signal type
Image of page 7

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

View Full Document Right Arrow Icon
Image of page 8
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern