SlideShare a Scribd company logo
1 of 39
BANGALORE INSTITUTE OF TECHNOLOGY
DEPARTMENT OF INFORMATION SCIENCE & ENGINEERING
SUBMITTED BY:
ANJAN B 1BI20IS016
DASRHAN P 1BI20IS027
LAKSHMISHA R A 1BI20IS049
MANOJ B KULKARNI 1BI20IS052
PRASANNAGOUDA S PATIL 1BI20IS063
Mrs. ANUPAMA K C
ASSISTANT PROFESSOR
DEPT OF ISE , BIT
FACULTY INCHARGE:
SIGNALS , THE UNIX KERNEL SUPPORT FOR SIGNALS
UNIX PROGRAMMING - 18CS56
PRESENTATION ON
INTRODUCTION
 Signals are software versions of hardware interrupts.
 Every signal has a name. These names all begin with the three characters SIG.
 For example, SIGABRT is the abort signal that is generated when a process calls the
abort function.
 A parent & child process can send signals to each other for process synchronization.
 Signals are defined as positive integer flags in the <signal.h> header file.
 No signal has a signal number of 0. We'll see in further slides that the kill function
uses the signal number of 0 for a special case. POSIX.1 calls this value the null signal.
 FreeBSD 5.2.1, Mac OS X 10.3, and Linux 2.4.22 support 31 different signals,
whereas Solaris 9 supports 38 different signals.
 FreeBSD 5.2.1 and Mac OS X 10.3 define the signals in <sys/signal.h>.
 Linux 2.4.22 defines the signals in <bits/signum.h>, and Solaris 9 defines them in
<sys/iso/signal_iso.h>.
CONDITIONS THAT CAN GENERATE SIGNALS
 The terminal-generated signals occur when users press certain terminal keys. Pressing the DELETE
key on the terminal (or Control-C on many systems) normally causes the interrupt signal (SIGINT)
to be generated. This is how to stop a runaway program.
 Hardware exceptions generate signals: divide by 0, invalid memory reference, and the like. These
conditions are usually detected by the hardware, and the kernel is notified. The kernel then
generates the appropriate signal for the process that was running at the time the condition occurred.
For example, SIGSEGV is generated for a process that executes an invalid memory reference.
 The kill(2) function allows a process to send any signal to another process or process
group. Naturally, there are limitations: we have to be the owner of the process that
we're sending the signal to, or we have to be the superuser.
 The kill(1) command allows us to send signals to other processes. This program is just
an interface to the kill function. This command is often used to terminate a runaway
background process.
 Software conditions can generate signals when something happens about which the
process should be notified. These aren't hardware-generated conditions. Examples are
SIGURG (generated when out-of-band data arrives over a network connection),
SIGPIPE (generated when a process writes to a pipe after the reader of the pipe has
terminated)
Contd.
DISPOSITION OF THE SIGNAL
We can tell the kernel to do one of three things when a signal occurs. We call this the disposition of the
signal, or the action associated with a signal.
 Ignore the signal.
 This works for most signals, but two signals can never be ignored: SIGKILL and SIGSTOP.
 The reason these two signals can't be ignored is to provide the kernel and the superuser with a surefire
way of either killing or stopping any process.
 Also, if we ignore some of the signals that are generated by a hardware exception (such as illegal
memory reference or divide by 0), the behavior of the process is undefined.
 Let the default action apply.
 Every signal has a default action.
 Note that the default action for most signals is to terminate the process.
 Catch the signal.
 We tell the kernel to call a function of ours whenever the signal occurs.
 In our function, we can do whatever we want to handle the condition. If we're writing
a command interpreter, for example, when the user generates the interrupt signal at
the keyboard, we probably want to return to the main loop of the program,
terminating whatever command we were executing for the user.
 If the SIGCHLD signal is caught, it means that a child process has terminated, so the
signal-catching function can call waitpid to fetch the child's process ID and
termination status.
 As another example, if the process has created temporary files, we may want to write
a signal-catching function for the SIGTERM signal (the termination signal that is the
default signal sent by the kill command) to clean up the temporary files.
 Note that the two signals SIGKILL and SIGSTOP can't be caught.
Contd.
POSIX – Defined signals
Contd.
Contd.
 In Unix System V 3. cach entry in the kernel process table slot has an array of signal
Nags, one for each defined in the system
 When a signal is generated for a process, the kernel will set the corresponding signal
flag in the process table slot of the recipient process.
 If the recipient process is asleep (waiting a child to terminate or executing pause API)
the kernel will awaken the process by scheduling it.
 When the recipient process runs the kernel will check the process U-area that contains
an array of signal handling specifications, where each entry of the array corresponds to
a signal defined in the system.
 The kernel will consult the array to find out how the process will react to the pending
signal.
 If the array entry contains a zero value, the process will accept the default action of the
signal and the kernel will discard it.
The UNIX Kernal Support For Signals
 If the array entry contains a one value, the process will ignore the signal.
 Finally, if the array entry contains any other value, it is used as the function pointer for
a used defined signal hander routine.
 The kernel will setup the process to execute the function immediately, and the process
will return to its current point of execution (or to some other place if signal hander does
a long jump), if the signal hander does not terminate the process.
 If there are different signals pending on a process, the order in which they are sent to a
recipient process in undefined.
 If multiple instances of a signal are pending on a process, it is implementation -
dependent on whether a single instance or multiple instances of the signal will be
delivered to the process.
 In UNIX System V.3, each signal flag in a process table slot records only whether a
signal is pending, but not how many of them are present.
Contd.
 All Unix Systems and ANSI – C support the signal API, which can be used to define
the per-signal handling method.
 The function prototype of the signal is:
 signal_num is the signal identifier like SIGINT or SIGTERM defined in the <signal.h>
handler is the function pointer of a user defined signal handler function. This function
should take an integer formal argument and does not return any value.
 Example below attempts to catch the SIGTERM, ignores the SIGINT and accepts the
default action of the SIGSEGV signal.
Signals
 The SIG_IGN & SIG_DFL are manifest constants defined in <signal.h>
#define SIG_IGN void(*)(int) 1 //Ignore the signal
#define SIG_DFL void(*)(int) 0 //Default action7.
 The return value of signal API is the previous signal handler for the signal.
 The pause API suspends the calling process until it is interrupted by the signal and the
corresponding signal handler does a return.
 The sigset arguments and return value is the same as that of signal.
 Both the functions set signal handling methods for any named signal, but signal API is
unreliable and sigset is reliable.
 this means that when a signal is set to be caught by a signal handler via sigset when
multiple instances of the signal arrive one of them is handled while other instances are
blocked. Further the signal handler is not reset to SIG_DFT when it is invoked.
 UNIX system V.3 and V.4 support the sigset API, which has the same prototype and
similar use a signal.
Calculating letter frequencies
Archiving old files automatically
Extracting system hardware info.
Encryption and Decryption of files
Guessing a number
Questions with answers
1)
Unixppt (1) (1).pptx
Unixppt (1) (1).pptx

More Related Content

Similar to Unixppt (1) (1).pptx

Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
swena_gupta
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
swena_gupta
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
swena_gupta
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
ssusere5db05
 

Similar to Unixppt (1) (1).pptx (20)

Erlang real time
Erlang real timeErlang real time
Erlang real time
 
Signal
SignalSignal
Signal
 
07 Systems Software Programming-IPC-Signals.pptx
07 Systems Software Programming-IPC-Signals.pptx07 Systems Software Programming-IPC-Signals.pptx
07 Systems Software Programming-IPC-Signals.pptx
 
Dsp class 1
Dsp class 1Dsp class 1
Dsp class 1
 
MyShell - English
MyShell - EnglishMyShell - English
MyShell - English
 
The Ring programming language version 1.6 book - Part 83 of 189
The Ring programming language version 1.6 book - Part 83 of 189The Ring programming language version 1.6 book - Part 83 of 189
The Ring programming language version 1.6 book - Part 83 of 189
 
Wireless Ad Hoc Networks
Wireless Ad Hoc NetworksWireless Ad Hoc Networks
Wireless Ad Hoc Networks
 
Dsp Datapath
Dsp DatapathDsp Datapath
Dsp Datapath
 
6. introduction to digital electronics
6. introduction to digital electronics6. introduction to digital electronics
6. introduction to digital electronics
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
Lab report 201001067_201001104
Lab report 201001067_201001104Lab report 201001067_201001104
Lab report 201001067_201001104
 
dsp.pdf
dsp.pdfdsp.pdf
dsp.pdf
 
Interrupts
InterruptsInterrupts
Interrupts
 
NetSIm Technology Library- Cognitive radio
NetSIm Technology Library- Cognitive radioNetSIm Technology Library- Cognitive radio
NetSIm Technology Library- Cognitive radio
 
Real time signal processing
Real time signal processingReal time signal processing
Real time signal processing
 
Project_report_on_Attendance_system
 Project_report_on_Attendance_system Project_report_on_Attendance_system
Project_report_on_Attendance_system
 
Lec2
Lec2Lec2
Lec2
 
arduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdfarduinocourse-180308074529 (1).pdf
arduinocourse-180308074529 (1).pdf
 
Arduino course
Arduino courseArduino course
Arduino course
 

Recently uploaded

一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
uodye
 
(👉Ridhima)👉VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
(👉Ridhima)👉VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...(👉Ridhima)👉VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
(👉Ridhima)👉VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
motiram463
 
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night StandCall Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men 🔝Muzaffarpur🔝 ...
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men  🔝Muzaffarpur🔝  ...➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men  🔝Muzaffarpur🔝  ...
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men 🔝Muzaffarpur🔝 ...
amitlee9823
 
Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
amitlee9823
 
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
tufbav
 
Makarba ( Call Girls ) Ahmedabad ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
Makarba ( Call Girls ) Ahmedabad ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...Makarba ( Call Girls ) Ahmedabad ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
Makarba ( Call Girls ) Ahmedabad ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
Naicy mandal
 
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
amitlee9823
 
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
amitlee9823
 
Just Call Vip call girls godhra Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls godhra Escorts ☎️9352988975 Two shot with one girl (...Just Call Vip call girls godhra Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls godhra Escorts ☎️9352988975 Two shot with one girl (...
gajnagarg
 
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
drmarathore
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
CHEAP Call Girls in Hauz Quazi (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Hauz Quazi  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Hauz Quazi  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Hauz Quazi (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

SM-N975F esquematico completo - reparación.pdf
SM-N975F esquematico completo - reparación.pdfSM-N975F esquematico completo - reparación.pdf
SM-N975F esquematico completo - reparación.pdf
 
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
一比一原版(Otago毕业证书)奥塔哥理工学院毕业证成绩单学位证靠谱定制
 
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
Get Premium Pimple Saudagar Call Girls (8005736733) 24x7 Rate 15999 with A/c ...
 
(👉Ridhima)👉VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
(👉Ridhima)👉VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...(👉Ridhima)👉VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
(👉Ridhima)👉VIP Model Call Girls Mulund ( Mumbai) Call ON 9967824496 Starting ...
 
Top Rated Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated  Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...Top Rated  Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
Top Rated Pune Call Girls Katraj ⟟ 6297143586 ⟟ Call Me For Genuine Sex Serv...
 
HLH PPT.ppt very important topic to discuss
HLH PPT.ppt very important topic to discussHLH PPT.ppt very important topic to discuss
HLH PPT.ppt very important topic to discuss
 
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night StandCall Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In RT Nagar ☎ 7737669865 🥵 Book Your One night Stand
 
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men 🔝Muzaffarpur🔝 ...
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men  🔝Muzaffarpur🔝  ...➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men  🔝Muzaffarpur🔝  ...
➥🔝 7737669865 🔝▻ Muzaffarpur Call-girls in Women Seeking Men 🔝Muzaffarpur🔝 ...
 
Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
Call Girls Banashankari Just Call 👗 7737669865 👗 Top Class Call Girl Service ...
 
Shikrapur Call Girls Most Awaited Fun 6297143586 High Profiles young Beautie...
Shikrapur Call Girls Most Awaited Fun  6297143586 High Profiles young Beautie...Shikrapur Call Girls Most Awaited Fun  6297143586 High Profiles young Beautie...
Shikrapur Call Girls Most Awaited Fun 6297143586 High Profiles young Beautie...
 
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
(ISHITA) Call Girls Service Aurangabad Call Now 8617697112 Aurangabad Escorts...
 
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
怎样办理斯威本科技大学毕业证(SUT毕业证书)成绩单留信认证
 
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Pimple Saudagar Call Me 7737669865 Budget Friendly No Advance Booking
 
Makarba ( Call Girls ) Ahmedabad ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
Makarba ( Call Girls ) Ahmedabad ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...Makarba ( Call Girls ) Ahmedabad ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
Makarba ( Call Girls ) Ahmedabad ✔ 6297143586 ✔ Hot Model With Sexy Bhabi Rea...
 
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
Vip Mumbai Call Girls Andheri East Call On 9920725232 With Body to body massa...
 
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
Kothanur Call Girls Service: 🍓 7737669865 🍓 High Profile Model Escorts | Bang...
 
Just Call Vip call girls godhra Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls godhra Escorts ☎️9352988975 Two shot with one girl (...Just Call Vip call girls godhra Escorts ☎️9352988975 Two shot with one girl (...
Just Call Vip call girls godhra Escorts ☎️9352988975 Two shot with one girl (...
 
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
Abort pregnancy in research centre+966_505195917 abortion pills in Kuwait cyt...
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
Call Now ≽ 9953056974 ≼🔝 Call Girls In Yusuf Sarai ≼🔝 Delhi door step delevry≼🔝
 
CHEAP Call Girls in Hauz Quazi (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Hauz Quazi  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Hauz Quazi  (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Hauz Quazi (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 

Unixppt (1) (1).pptx

  • 1. BANGALORE INSTITUTE OF TECHNOLOGY DEPARTMENT OF INFORMATION SCIENCE & ENGINEERING SUBMITTED BY: ANJAN B 1BI20IS016 DASRHAN P 1BI20IS027 LAKSHMISHA R A 1BI20IS049 MANOJ B KULKARNI 1BI20IS052 PRASANNAGOUDA S PATIL 1BI20IS063 Mrs. ANUPAMA K C ASSISTANT PROFESSOR DEPT OF ISE , BIT FACULTY INCHARGE: SIGNALS , THE UNIX KERNEL SUPPORT FOR SIGNALS UNIX PROGRAMMING - 18CS56 PRESENTATION ON
  • 2. INTRODUCTION  Signals are software versions of hardware interrupts.  Every signal has a name. These names all begin with the three characters SIG.  For example, SIGABRT is the abort signal that is generated when a process calls the abort function.  A parent & child process can send signals to each other for process synchronization.  Signals are defined as positive integer flags in the <signal.h> header file.  No signal has a signal number of 0. We'll see in further slides that the kill function uses the signal number of 0 for a special case. POSIX.1 calls this value the null signal.  FreeBSD 5.2.1, Mac OS X 10.3, and Linux 2.4.22 support 31 different signals, whereas Solaris 9 supports 38 different signals.  FreeBSD 5.2.1 and Mac OS X 10.3 define the signals in <sys/signal.h>.  Linux 2.4.22 defines the signals in <bits/signum.h>, and Solaris 9 defines them in <sys/iso/signal_iso.h>.
  • 3. CONDITIONS THAT CAN GENERATE SIGNALS  The terminal-generated signals occur when users press certain terminal keys. Pressing the DELETE key on the terminal (or Control-C on many systems) normally causes the interrupt signal (SIGINT) to be generated. This is how to stop a runaway program.  Hardware exceptions generate signals: divide by 0, invalid memory reference, and the like. These conditions are usually detected by the hardware, and the kernel is notified. The kernel then generates the appropriate signal for the process that was running at the time the condition occurred. For example, SIGSEGV is generated for a process that executes an invalid memory reference.
  • 4.  The kill(2) function allows a process to send any signal to another process or process group. Naturally, there are limitations: we have to be the owner of the process that we're sending the signal to, or we have to be the superuser.  The kill(1) command allows us to send signals to other processes. This program is just an interface to the kill function. This command is often used to terminate a runaway background process.  Software conditions can generate signals when something happens about which the process should be notified. These aren't hardware-generated conditions. Examples are SIGURG (generated when out-of-band data arrives over a network connection), SIGPIPE (generated when a process writes to a pipe after the reader of the pipe has terminated) Contd.
  • 5. DISPOSITION OF THE SIGNAL We can tell the kernel to do one of three things when a signal occurs. We call this the disposition of the signal, or the action associated with a signal.  Ignore the signal.  This works for most signals, but two signals can never be ignored: SIGKILL and SIGSTOP.  The reason these two signals can't be ignored is to provide the kernel and the superuser with a surefire way of either killing or stopping any process.  Also, if we ignore some of the signals that are generated by a hardware exception (such as illegal memory reference or divide by 0), the behavior of the process is undefined.  Let the default action apply.  Every signal has a default action.  Note that the default action for most signals is to terminate the process.
  • 6.  Catch the signal.  We tell the kernel to call a function of ours whenever the signal occurs.  In our function, we can do whatever we want to handle the condition. If we're writing a command interpreter, for example, when the user generates the interrupt signal at the keyboard, we probably want to return to the main loop of the program, terminating whatever command we were executing for the user.  If the SIGCHLD signal is caught, it means that a child process has terminated, so the signal-catching function can call waitpid to fetch the child's process ID and termination status.  As another example, if the process has created temporary files, we may want to write a signal-catching function for the SIGTERM signal (the termination signal that is the default signal sent by the kill command) to clean up the temporary files.  Note that the two signals SIGKILL and SIGSTOP can't be caught. Contd.
  • 10.  In Unix System V 3. cach entry in the kernel process table slot has an array of signal Nags, one for each defined in the system  When a signal is generated for a process, the kernel will set the corresponding signal flag in the process table slot of the recipient process.  If the recipient process is asleep (waiting a child to terminate or executing pause API) the kernel will awaken the process by scheduling it.  When the recipient process runs the kernel will check the process U-area that contains an array of signal handling specifications, where each entry of the array corresponds to a signal defined in the system.  The kernel will consult the array to find out how the process will react to the pending signal.  If the array entry contains a zero value, the process will accept the default action of the signal and the kernel will discard it. The UNIX Kernal Support For Signals
  • 11.  If the array entry contains a one value, the process will ignore the signal.  Finally, if the array entry contains any other value, it is used as the function pointer for a used defined signal hander routine.  The kernel will setup the process to execute the function immediately, and the process will return to its current point of execution (or to some other place if signal hander does a long jump), if the signal hander does not terminate the process.  If there are different signals pending on a process, the order in which they are sent to a recipient process in undefined.  If multiple instances of a signal are pending on a process, it is implementation - dependent on whether a single instance or multiple instances of the signal will be delivered to the process.  In UNIX System V.3, each signal flag in a process table slot records only whether a signal is pending, but not how many of them are present. Contd.
  • 12.  All Unix Systems and ANSI – C support the signal API, which can be used to define the per-signal handling method.  The function prototype of the signal is:  signal_num is the signal identifier like SIGINT or SIGTERM defined in the <signal.h> handler is the function pointer of a user defined signal handler function. This function should take an integer formal argument and does not return any value.  Example below attempts to catch the SIGTERM, ignores the SIGINT and accepts the default action of the SIGSEGV signal. Signals
  • 13.  The SIG_IGN & SIG_DFL are manifest constants defined in <signal.h> #define SIG_IGN void(*)(int) 1 //Ignore the signal #define SIG_DFL void(*)(int) 0 //Default action7.  The return value of signal API is the previous signal handler for the signal.  The pause API suspends the calling process until it is interrupted by the signal and the corresponding signal handler does a return.
  • 14.  The sigset arguments and return value is the same as that of signal.  Both the functions set signal handling methods for any named signal, but signal API is unreliable and sigset is reliable.  this means that when a signal is set to be caught by a signal handler via sigset when multiple instances of the signal arrive one of them is handled while other instances are blocked. Further the signal handler is not reset to SIG_DFT when it is invoked.  UNIX system V.3 and V.4 support the sigset API, which has the same prototype and similar use a signal.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21. Archiving old files automatically
  • 22.
  • 23.
  • 24.
  • 25.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 34.
  • 36.