fork download
  1. import signal
  2. import os
  3. import time
  4. import threading
  5.  
  6. def receive_signal(signum, stack):
  7. print 'Received:', signum
  8.  
  9. signal.signal(signal.SIGUSR1, receive_signal)
  10. signal.signal(signal.SIGUSR2, receive_signal)
  11. signal.signal(signal.SIGALRM, receive_signal) # <-- THIS LINE ADDED
  12.  
  13. print 'My PID is:', os.getpid()
  14.  
  15. pid = os.getpid()
  16. thread = threading.Thread(
  17. target=lambda: (
  18. time.sleep(10),
  19. os.kill(pid, signal.SIGUSR1)))
  20. thread.start()
  21.  
  22. while True:
  23. print 'Waiting...'
  24. time.sleep(3)
  25.  
Time limit exceeded #stdin #stdout 5s 16848KB
stdin
Standard input is empty
stdout
Standard output is empty