19 lines
376 B
Python
19 lines
376 B
Python
import time
|
|
import os
|
|
import signal
|
|
|
|
def alarm_handler(signum, frame):
|
|
print("I'm an alarm hear me ring! (my ID is {})".format(signum))
|
|
|
|
def main():
|
|
print("I'm {}".format(os.getpid()))
|
|
while True:
|
|
time.sleep(1)
|
|
|
|
if __name__ == "__main__":
|
|
signal.signal(signal.SIGALRM, alarm_handler)
|
|
try:
|
|
main()
|
|
except Exception as e:
|
|
print(e)
|