SlideShare a Scribd company logo
1 of 15
Signals



© 2010 Anil Kumar Pugalia <email@sarika-pugs.com>
               All Rights Reserved.
What to Expect?
W's of a Signal
Signals in Linux
Signal Handlers
Signal related Functions
Program Exit Codes




        © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   2
                       All Rights Reserved.
Asynchronous Communication
In Kernel Space
  Interrupts (Hardware to Software)
  Soft Irqs (Software to Software)
What about User Space?
Moreover, between User Space & Kernel Space
Though only software to software requirement
Do System Calls take care of that?
Communication: Yes, but they are Synchronous
Asynchronous Solution is Signals
          © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   3
                         All Rights Reserved.
What is a Signal?
Asynchronous Trigger from Kernel Space or a Process to
another Process
Mechanisms for communicating with and manipulating
processes in Linux
Handled in User Space like Interrupts in Kernel Space
  Remains Pending on Masking. Once handled,
  Immediate processing without finishing the current function or
  even the current line of code. Possible options
    Ignore
    Execute the Default Handler
    Execute the User specified Handler



              © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>    4
                             All Rights Reserved.
Signals in Linux
Specified by a Number (currently 1-31)
Also, referred by Human readable Names
On Shell
  Type 'kill -l'
  Signal Operations: Using kill
In Programming / C
  Header: /usr/include/bits/signum.h
  Signal Operations: Shall discuss further
           © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   5
                          All Rights Reserved.
Signals Originate from
Kernel Space
 Typically on an illegal operation. Namely,
   SIGBUS (bus error),
   SIGSEGV (segmentation violation)
   SIGFPE (floating point exception)
 Others like SIGCHLD
A Process
 Synchronously using kill system call


        © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   6
                       All Rights Reserved.
Signal Handler Registration
Using signal(sig_no, handler)
  Non-portable except for SIG_DFL & SIG_IGN as handlers
Using sigaction(sig_no, action, old_action)
  action & new_action are pointers to sigaction structures
  action contains the desired disposition
  old_action receives the previous disposition
  Their sa_handler field takes one of the three values
    SIG_DFL
    SIG_IGN
    A pointer to a signal handler function
Signal Hanlder Prototype
  void signal_handler(int sig_no);
Exceptions to Registration: SIGKILL, SIGSTOP
                © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   7
                               All Rights Reserved.
Sensitivity of Signal Handlers
Time Sensitive like Interrupt Handlers
Perform the minimum work necessary &
  Return control to the main program, Or
  Terminate the program
Mostly, they just record the signal
occurrence
  And the main program does the processing



         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   8
                        All Rights Reserved.
Signal in a Signal
Signal interrupting a signal handler
  Rare Occurrence but could be a Problem
  Difficult to diagnose & debug
  Assigning to globals can be dangerous
Solutions
  Self is restricted by default
    Unless SA_NODEFER flag is used
  Disable other signals in signal handlers
    By setting sa_mask using sigsetops during registration
  Protect the global variables by using sig_atomic_t type

            © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   9
                           All Rights Reserved.
Signal related Functions
raise
  Sends a signal to calling thread
kill, killpg
  Sends a signal to a specified process or group of processes
tkill, tgkill, pthread_kill
  Sends a signal to a specified thread
sigqueue
  Sends a real-time signal with accompanying data to a specified process
pause, sigsuspend
  Suspends the calling thread until delivery of a signal whose action is
  either to execute a signal handler or to terminate the process
sigwaitinfo, sigtimedwait, sigwait, signalfd
  Accepts signals synchronously
                © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>          10
                               All Rights Reserved.
Signal related Functions ...
alarm(unsigned int secs);
  Schedules an alarm signal (SIGALRM) to be
  sent to the calling process after “secs”
  seconds
  Should not be mixed with setitimer / sleep
abort();
  Causes abnormal process termination by
  raising abort signal (SIGABRT)


           © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   11
                          All Rights Reserved.
Process Termination Revisited
Normal: System Call 'exit' is invoked
  With zero – Success Exit
  With non-zero value – Error Exit
Abnormal: A Signal has terminated it
  From Kernel Space for a Bug – Fatal Exit
    SIGBUS
    SIGSEGV
    SIGFPE
  From a Process – Kill Exit
    SIGINT (Ctrl + C)
    SIGTERM
    SIGABRT / abort()
    ...
              © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   12
                             All Rights Reserved.
Exit Codes Decoded
8-bit unsigned integer
Range: 0-255
Normal Termination (using exit(value);)
  “value” should be always between 0 and 127
  Exit code is “value”
Abnormal Termination (by signal)
  Exit code is 128 + “signal”


         © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   13
                        All Rights Reserved.
What all have we learnt?
W's of a Signal
Signals in Linux
Signal Handlers
Signal related Functions
Program Exit Codes




        © 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   14
                       All Rights Reserved.
Any Queries?




© 2010 Anil Kumar Pugalia <email@sarika-pugs.com>   15
               All Rights Reserved.

More Related Content

What's hot (20)

Kernel Debugging & Profiling
Kernel Debugging & ProfilingKernel Debugging & Profiling
Kernel Debugging & Profiling
 
Architecture Porting
Architecture PortingArchitecture Porting
Architecture Porting
 
Interrupts
InterruptsInterrupts
Interrupts
 
Linux DMA Engine
Linux DMA EngineLinux DMA Engine
Linux DMA Engine
 
Kernel Timing Management
Kernel Timing ManagementKernel Timing Management
Kernel Timing Management
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
Embedded Storage Management
Embedded Storage ManagementEmbedded Storage Management
Embedded Storage Management
 
POSIX Threads
POSIX ThreadsPOSIX Threads
POSIX Threads
 
Mobile Hacking using Linux Drivers
Mobile Hacking using Linux DriversMobile Hacking using Linux Drivers
Mobile Hacking using Linux Drivers
 
Embedded C
Embedded CEmbedded C
Embedded C
 
Synchronization
SynchronizationSynchronization
Synchronization
 
Embedded Software Design
Embedded Software DesignEmbedded Software Design
Embedded Software Design
 
Introduction to Linux
Introduction to LinuxIntroduction to Linux
Introduction to Linux
 
BeagleBoard-xM Booting Process
BeagleBoard-xM Booting ProcessBeagleBoard-xM Booting Process
BeagleBoard-xM Booting Process
 
Kernel Programming
Kernel ProgrammingKernel Programming
Kernel Programming
 
Linux User Space Debugging & Profiling
Linux User Space Debugging & ProfilingLinux User Space Debugging & Profiling
Linux User Space Debugging & Profiling
 
Video Drivers
Video DriversVideo Drivers
Video Drivers
 
Threads
ThreadsThreads
Threads
 
SPI Drivers
SPI DriversSPI Drivers
SPI Drivers
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 

Viewers also liked (16)

System Calls
System CallsSystem Calls
System Calls
 
Inter Process Communication
Inter Process CommunicationInter Process Communication
Inter Process Communication
 
Network Drivers
Network DriversNetwork Drivers
Network Drivers
 
References
ReferencesReferences
References
 
Character Drivers
Character DriversCharacter Drivers
Character Drivers
 
Board Bringup
Board BringupBoard Bringup
Board Bringup
 
Bootloaders
BootloadersBootloaders
Bootloaders
 
Shell Scripting
Shell ScriptingShell Scripting
Shell Scripting
 
Functional Programming with LISP
Functional Programming with LISPFunctional Programming with LISP
Functional Programming with LISP
 
gcc and friends
gcc and friendsgcc and friends
gcc and friends
 
Linux File System
Linux File SystemLinux File System
Linux File System
 
Linux Memory Management
Linux Memory ManagementLinux Memory Management
Linux Memory Management
 
PCI Drivers
PCI DriversPCI Drivers
PCI Drivers
 
File Systems
File SystemsFile Systems
File Systems
 
BeagleBoard-xM Bootloaders
BeagleBoard-xM BootloadersBeagleBoard-xM Bootloaders
BeagleBoard-xM Bootloaders
 
BeagleBone Black Bootloaders
BeagleBone Black BootloadersBeagleBone Black Bootloaders
BeagleBone Black Bootloaders
 

Similar to Signals

Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in LinuxTushar B Kute
 
AOS Chapter 6 for internal.docx
AOS Chapter 6 for internal.docxAOS Chapter 6 for internal.docx
AOS Chapter 6 for internal.docxKomlikaTaru
 
SOGNAL DAEMON AND PROCESSING CRYPTOGRAPHY NOTES
SOGNAL DAEMON AND PROCESSING CRYPTOGRAPHY NOTESSOGNAL DAEMON AND PROCESSING CRYPTOGRAPHY NOTES
SOGNAL DAEMON AND PROCESSING CRYPTOGRAPHY NOTES4SF20CS057LESTONREGO
 
Course 102: Lecture 19: Using Signals
Course 102: Lecture 19: Using Signals Course 102: Lecture 19: Using Signals
Course 102: Lecture 19: Using Signals Ahmed El-Arabawy
 
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.pptxKushalSrivastava23
 
System Programming Assignment Help- Signals
System Programming Assignment Help- SignalsSystem Programming Assignment Help- Signals
System Programming Assignment Help- SignalsHelpWithAssignment.com
 
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی Mohammad Reza Kamalifard
 
PRESENTATION ON PLC AND SCADA
PRESENTATION ON PLC AND SCADAPRESENTATION ON PLC AND SCADA
PRESENTATION ON PLC AND SCADAAnandKumarJha33
 
DIGITAL SIGNAL PROCESSOR OVERVIEW
DIGITAL SIGNAL PROCESSOR OVERVIEWDIGITAL SIGNAL PROCESSOR OVERVIEW
DIGITAL SIGNAL PROCESSOR OVERVIEWsathish sak
 
PPT of PLC and SCADA
PPT of PLC and SCADAPPT of PLC and SCADA
PPT of PLC and SCADAMohseen1234
 
AWS Loft Talk: Behind the Scenes with SignalFx
AWS Loft Talk: Behind the Scenes with SignalFxAWS Loft Talk: Behind the Scenes with SignalFx
AWS Loft Talk: Behind the Scenes with SignalFxSignalFx
 
No liftoff, touchdown, or heartbeat shall miss because of a software failure
No liftoff, touchdown, or heartbeat shall miss because of a software failureNo liftoff, touchdown, or heartbeat shall miss because of a software failure
No liftoff, touchdown, or heartbeat shall miss because of a software failureRogue Wave Software
 
Routeco cyber security and secure remote access 1 01
Routeco cyber security and secure remote access 1 01Routeco cyber security and secure remote access 1 01
Routeco cyber security and secure remote access 1 01RoutecoMarketing
 
Wireless stepper motor control using zigbee
Wireless stepper motor control  using zigbeeWireless stepper motor control  using zigbee
Wireless stepper motor control using zigbeesavan Darji
 

Similar to Signals (20)

Signal Handling in Linux
Signal Handling in LinuxSignal Handling in Linux
Signal Handling in Linux
 
Usp notes unit6-8
Usp notes unit6-8Usp notes unit6-8
Usp notes unit6-8
 
AOS Chapter 6 for internal.docx
AOS Chapter 6 for internal.docxAOS Chapter 6 for internal.docx
AOS Chapter 6 for internal.docx
 
SOGNAL DAEMON AND PROCESSING CRYPTOGRAPHY NOTES
SOGNAL DAEMON AND PROCESSING CRYPTOGRAPHY NOTESSOGNAL DAEMON AND PROCESSING CRYPTOGRAPHY NOTES
SOGNAL DAEMON AND PROCESSING CRYPTOGRAPHY NOTES
 
Unixppt (1) (1).pptx
Unixppt (1) (1).pptxUnixppt (1) (1).pptx
Unixppt (1) (1).pptx
 
Course 102: Lecture 19: Using Signals
Course 102: Lecture 19: Using Signals Course 102: Lecture 19: Using Signals
Course 102: Lecture 19: Using Signals
 
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
 
System Programming Assignment Help- Signals
System Programming Assignment Help- SignalsSystem Programming Assignment Help- Signals
System Programming Assignment Help- Signals
 
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
اسلاید ارائه دوم جلسه ۱۰ کلاس پایتون برای هکر های قانونی
 
PRESENTATION ON PLC AND SCADA
PRESENTATION ON PLC AND SCADAPRESENTATION ON PLC AND SCADA
PRESENTATION ON PLC AND SCADA
 
DEVENDRAPLC .pptx
DEVENDRAPLC .pptxDEVENDRAPLC .pptx
DEVENDRAPLC .pptx
 
DIGITAL SIGNAL PROCESSOR OVERVIEW
DIGITAL SIGNAL PROCESSOR OVERVIEWDIGITAL SIGNAL PROCESSOR OVERVIEW
DIGITAL SIGNAL PROCESSOR OVERVIEW
 
PPT of PLC and SCADA
PPT of PLC and SCADAPPT of PLC and SCADA
PPT of PLC and SCADA
 
AWS Loft Talk: Behind the Scenes with SignalFx
AWS Loft Talk: Behind the Scenes with SignalFxAWS Loft Talk: Behind the Scenes with SignalFx
AWS Loft Talk: Behind the Scenes with SignalFx
 
Erlang real time
Erlang real timeErlang real time
Erlang real time
 
No liftoff, touchdown, or heartbeat shall miss because of a software failure
No liftoff, touchdown, or heartbeat shall miss because of a software failureNo liftoff, touchdown, or heartbeat shall miss because of a software failure
No liftoff, touchdown, or heartbeat shall miss because of a software failure
 
Unix presentation.pdf
Unix presentation.pdfUnix presentation.pdf
Unix presentation.pdf
 
Routeco cyber security and secure remote access 1 01
Routeco cyber security and secure remote access 1 01Routeco cyber security and secure remote access 1 01
Routeco cyber security and secure remote access 1 01
 
Biometric Access and Attendance Terminal
Biometric Access and Attendance TerminalBiometric Access and Attendance Terminal
Biometric Access and Attendance Terminal
 
Wireless stepper motor control using zigbee
Wireless stepper motor control  using zigbeeWireless stepper motor control  using zigbee
Wireless stepper motor control using zigbee
 

More from Anil Kumar Pugalia (9)

File System Modules
File System ModulesFile System Modules
File System Modules
 
Processes
ProcessesProcesses
Processes
 
System Calls
System CallsSystem Calls
System Calls
 
Playing with R L C Circuits
Playing with R L C CircuitsPlaying with R L C Circuits
Playing with R L C Circuits
 
Audio Drivers
Audio DriversAudio Drivers
Audio Drivers
 
Power of vi
Power of viPower of vi
Power of vi
 
"make" system
"make" system"make" system
"make" system
 
Hardware Design for Software Hackers
Hardware Design for Software HackersHardware Design for Software Hackers
Hardware Design for Software Hackers
 
RPM Building
RPM BuildingRPM Building
RPM Building
 

Recently uploaded

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...panagenda
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 

Recently uploaded (20)

Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
Why device, WIFI, and ISP insights are crucial to supporting remote Microsoft...
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 

Signals

  • 1. Signals © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> All Rights Reserved.
  • 2. What to Expect? W's of a Signal Signals in Linux Signal Handlers Signal related Functions Program Exit Codes © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 2 All Rights Reserved.
  • 3. Asynchronous Communication In Kernel Space Interrupts (Hardware to Software) Soft Irqs (Software to Software) What about User Space? Moreover, between User Space & Kernel Space Though only software to software requirement Do System Calls take care of that? Communication: Yes, but they are Synchronous Asynchronous Solution is Signals © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 3 All Rights Reserved.
  • 4. What is a Signal? Asynchronous Trigger from Kernel Space or a Process to another Process Mechanisms for communicating with and manipulating processes in Linux Handled in User Space like Interrupts in Kernel Space Remains Pending on Masking. Once handled, Immediate processing without finishing the current function or even the current line of code. Possible options Ignore Execute the Default Handler Execute the User specified Handler © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 4 All Rights Reserved.
  • 5. Signals in Linux Specified by a Number (currently 1-31) Also, referred by Human readable Names On Shell Type 'kill -l' Signal Operations: Using kill In Programming / C Header: /usr/include/bits/signum.h Signal Operations: Shall discuss further © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 5 All Rights Reserved.
  • 6. Signals Originate from Kernel Space Typically on an illegal operation. Namely, SIGBUS (bus error), SIGSEGV (segmentation violation) SIGFPE (floating point exception) Others like SIGCHLD A Process Synchronously using kill system call © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 6 All Rights Reserved.
  • 7. Signal Handler Registration Using signal(sig_no, handler) Non-portable except for SIG_DFL & SIG_IGN as handlers Using sigaction(sig_no, action, old_action) action & new_action are pointers to sigaction structures action contains the desired disposition old_action receives the previous disposition Their sa_handler field takes one of the three values SIG_DFL SIG_IGN A pointer to a signal handler function Signal Hanlder Prototype void signal_handler(int sig_no); Exceptions to Registration: SIGKILL, SIGSTOP © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 7 All Rights Reserved.
  • 8. Sensitivity of Signal Handlers Time Sensitive like Interrupt Handlers Perform the minimum work necessary & Return control to the main program, Or Terminate the program Mostly, they just record the signal occurrence And the main program does the processing © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 8 All Rights Reserved.
  • 9. Signal in a Signal Signal interrupting a signal handler Rare Occurrence but could be a Problem Difficult to diagnose & debug Assigning to globals can be dangerous Solutions Self is restricted by default Unless SA_NODEFER flag is used Disable other signals in signal handlers By setting sa_mask using sigsetops during registration Protect the global variables by using sig_atomic_t type © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 9 All Rights Reserved.
  • 10. Signal related Functions raise Sends a signal to calling thread kill, killpg Sends a signal to a specified process or group of processes tkill, tgkill, pthread_kill Sends a signal to a specified thread sigqueue Sends a real-time signal with accompanying data to a specified process pause, sigsuspend Suspends the calling thread until delivery of a signal whose action is either to execute a signal handler or to terminate the process sigwaitinfo, sigtimedwait, sigwait, signalfd Accepts signals synchronously © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 10 All Rights Reserved.
  • 11. Signal related Functions ... alarm(unsigned int secs); Schedules an alarm signal (SIGALRM) to be sent to the calling process after “secs” seconds Should not be mixed with setitimer / sleep abort(); Causes abnormal process termination by raising abort signal (SIGABRT) © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 11 All Rights Reserved.
  • 12. Process Termination Revisited Normal: System Call 'exit' is invoked With zero – Success Exit With non-zero value – Error Exit Abnormal: A Signal has terminated it From Kernel Space for a Bug – Fatal Exit SIGBUS SIGSEGV SIGFPE From a Process – Kill Exit SIGINT (Ctrl + C) SIGTERM SIGABRT / abort() ... © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 12 All Rights Reserved.
  • 13. Exit Codes Decoded 8-bit unsigned integer Range: 0-255 Normal Termination (using exit(value);) “value” should be always between 0 and 127 Exit code is “value” Abnormal Termination (by signal) Exit code is 128 + “signal” © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 13 All Rights Reserved.
  • 14. What all have we learnt? W's of a Signal Signals in Linux Signal Handlers Signal related Functions Program Exit Codes © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 14 All Rights Reserved.
  • 15. Any Queries? © 2010 Anil Kumar Pugalia <email@sarika-pugs.com> 15 All Rights Reserved.