Skip to content

Instantly share code, notes, and snippets.

@xiazhibin
Created January 19, 2018 03:44
Show Gist options
  • Save xiazhibin/b1d3fb0837724e52354674d0cb65c4e9 to your computer and use it in GitHub Desktop.
Save xiazhibin/b1d3fb0837724e52354674d0cb65c4e9 to your computer and use it in GitHub Desktop.
list all signal
import signal
def handle_hup(sig, frame):
print "get signal: %s"%sig
signal.signal(signal.SIGHUP, handle_hup)
if __name__ == '__main__':
ign = signal.SIG_IGN
dfl = signal.SIG_DFL
print "SIG_IGN", ign
print "SIG_DFL", dfl
print "*" * 40
for name in dir(signal):
if name[:3] == 'SIG' and name[3] != '_':
signum = getattr(signal, name)
gsig = signal.getsignal(signum)
print name, signum, gsig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment