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

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
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
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
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
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 

Recently uploaded (20)

How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.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
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
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.
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
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
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
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
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 

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.