linux_course_doc/modules/qualifying/assets/processes_ex_03.py

19 lines
376 B
Python
Raw Permalink Normal View History

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)