def persist_child(self, child_state, persistent_level=0):
        """
        This is used to carry child shell state to its parent shell
        :param ShState child_state: Child state
        """
        if persistent_level == 0:
            # restore old state
            if os.getcwd() != child_state.enclosed_cwd:
                os.chdir(child_state.enclosed_cwd)
                # TODO: return status?

        elif persistent_level == 1:
            # update state
            self.aliases = dict(child_state.aliases)
            self.enclosing_aliases = child_state.aliases
            self.enclosed_cwd = self.enclosing_cwd = os.getcwd()
            self.environ = dict(child_state.environ)
            self.enclosing_environ = child_state.environ
            self.sys_path = child_state.sys_path[:]

        elif persistent_level == 2:
            # ensure future children will have child state
            self.enclosing_aliases = child_state.aliases
            self.enclosing_environ = child_state.environ
            self.enclosing_cwd = os.getcwd()
            # TODO: return status?
            if self.enclosed_cwd is not None:
                os.chdir(self.enclosed_cwd)

        This is used to carry child shell state to its parent shell
        :param ShState child_state: Child state
        
system/shthreads.py