Signal handle SIGUSR1 to print status

This commit is contained in:
Stephen Seo 2023-10-27 16:10:21 +09:00
parent 58040766e8
commit d7941a589d

View file

@ -1707,16 +1707,21 @@ def validate_and_verify_paths(other_state: dict[str, Union[None, str]]):
def signal_handler(sig, frame): def signal_handler(sig, frame):
"""Handle SIGINT""" """Handle SIGINT and SIGUSR1."""
global OTHER_STATE, PKG_STATE global OTHER_STATE, PKG_STATE
if OTHER_STATE is not None and PKG_STATE is not None: if OTHER_STATE is not None and PKG_STATE is not None:
print_state_info_and_get_update_list(OTHER_STATE, PKG_STATE) print_state_info_and_get_update_list(OTHER_STATE, PKG_STATE)
if signal.Signals(sig) is not signal.SIGINT:
return
sys.exit(0) sys.exit(0)
if signal.Signals(sig) is not signal.SIGINT:
return
sys.exit(1) sys.exit(1)
if __name__ == "__main__": if __name__ == "__main__":
signal.signal(signal.SIGINT, signal_handler) signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGUSR1, signal_handler)
editor = None editor = None
parser = argparse.ArgumentParser(description="Update AUR pkgs") parser = argparse.ArgumentParser(description="Update AUR pkgs")
parser.add_argument( parser.add_argument(