Advertisement
rfmonk

signal_signal.py

Feb 3rd, 2014
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. # this is from The Python
  4. # Standard Library by example
  5. # ISBN13: 9780321767349
  6.  
  7. import signal
  8. import os
  9. import time
  10.  
  11.  
  12. def receive_signal(signum, stack):
  13.     print 'Received:', signum
  14.  
  15. # Register signal handlers
  16. signal.signal(signal.SIGUSR1, receive_signal)
  17. signal.signal(signal.SIGUSR2, receive_signal)
  18.  
  19. # Print the process ID so it can be used with 'kill'
  20. # to send this program signals.
  21. print 'My PID is:', os.getpid()
  22.  
  23. while True:
  24.     print 'Waiting... '
  25.     time.sleep(3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement