3. # Signals
Allows handling of Asynchronous events
SIGKILL is what gets sent when you use "kill -9"
Programming with Signals is easy
Mohammad reza Kamalifard
Kamalifard.ir/pysec101
4. Signals
$ man 7 signal for list of Signals (in unix shell)
SIGINT Interrupt from keyboard when you press Ctrl + C
SIGKILL Kill signal
SIGINT 2 Term Interrupt from keyboard
SIGQUIT 3 Core Quit from keyboard
SIGILL 4 Core Illegal Instruction
SIGABRT 6 Core Abort signal from
abort(3)
SIGFPE 8 Core Floating point exception
SIGKILL 9 Term Kill signal
SIGSEGV 11 Core Invalid memory reference
Mohammad reza Kamalifard
Kamalifard.ir/pysec101
5. Signal Handler
import signal
# Signal handler
def ctrlc_handler(sign_value, frm):
print "Haha!You Cannot Kill me!"
print "Installing signal Handler"
signal.signal(signal.SIGINT, ctrlc_handler)
print "Done!"
while True:
pass
Mohammad reza Kamalifard
Kamalifard.ir/pysec101
7. This work is licensed under the Creative Commons
Attribution-NoDerivs 3.0 Unported License.
To view a copy of this license, visit http://creativecommons.org/licenses/by-nd/3.0/
Copyright 2013 Mohammad reza Kamalifard.
All rights reserved.