def sigterm_handler(signalnum: int, current_stack_frame: Any) -> None:
    strsignal = signal.strsignal
    print(f'Parent process {os.getpid()} received {strsignal(signalnum)} signal. Terminate all child processes first.')
    for child in multiprocessing.active_children():
        child.terminate()
        child.join()
    print(f'Parent process {os.getpid()} terminated successfully.')
    sys.exit(0)
def sigterm_handler(signalnum: int, current_stack_frame: Any) -> None:
    strsignal = signal.strsignal
    print(f'Parent process {os.getpid()} received {strsignal(signalnum)} signal. Terminate all child processes first.')
    for child in multiprocessing.active_children():
        child.terminate()
        child.join()
    print(f'Parent process {os.getpid()} terminated successfully.')
    sys.exit(0)