#!/usr/bin/env python3 import os import re import subprocess import sys # Calling shellscript, that calls us if __name__ == "__main__": child = False try: if re.match("__", os.path.basename(sys.argv[0])): print("Indirect child being called") child = True else: subprocess.check_call(["/bin/sh", "-e", "./shellpart.sh"]) except KeyboardInterrupt: if re.match("__", os.path.basename(sys.argv[0])): print("caught signint in child") else: print("caught signint in parent") sys.exit(0)