linux_introduction/assets/processes_ex_03.py

19 lines
376 B
Python
Raw Permalink Normal View History

2022-08-23 09:59:09 +02:00
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)