Exit gracefully on ctrl-C.
168158
def sigint_handler(signum, frame):
    """"""
    global _handled_int
    if not _handled_int:
        _handled_int = True
        if not _env_var_true("_REZ_QUIET_ON_SIG"):
            print >> sys.stderr, "Interrupted by user"
        sigbase_handler(signum, frame)
791040
def do_ctrlc(self, arg):
        '''  '''
        print('STOP')
        if self.arm.is_connected():
            self.arm.write('STOP')
540085
def _exit(self):
        
        self._removeInputPrompt()
        print(self._color(self.COLOR_YELLOW, 'CLOSING TERMINAL...')) 
        self.stop()
852828
def _complete_exit(self, cmd, args, text):
        """"""
        if args:
            return
        return [ x for x in { 'root', 'all', } \
                if x.startswith(text) ]
155243
def postloop(self) -> None:
        """"""
        code = self.exit_code if self.exit_code is not None else 0
        self.poutput('{!r} exiting with code: {}'.format(sys.argv[0], code))
464584
def exit_fullscreen(self):
        
        self.term.stream.write(self.term.exit_fullscreen)
        self.term.stream.write(self.term.normal_cursor)
452887
def postloop(self):
        
        cmd.Cmd.postloop(self)  # Clean up command completion
        d1_cli.impl.util.print_info("Exiting...")
149468
def function_end(self):
        """"""
        self.newline_label(self.shared.function_name + "_exit", True, True)
        self.move("%14", "%15")
        self.pop("%14")
        self.newline_text("RET", True)
617020
def exit(self):
        """"""
        # First detach all servo's, otherwise it somehow doesn't want to close...
        if hasattr(self, 'digital'):
            for pin in self.digital:
                if pin.mode == SERVO:
                    pin.mode = OUTPUT
        if hasattr(self, 'sp'):
            self.sp.close()
117170
def execute(self):
        """"""
        try:
            logging.debug("Entering IOLoop")
            self.loop.start()
            logging.debug("Leaving IOLoop")
        except KeyboardInterrupt:
            logging.debug("Leaving IOLoop by KeyboardInterrupt")
        finally:
            self.hw_communication.disconnect()
804153
def cmd(self, args=None, interact=True):
        """"""
        if args is None:
            parsed_args = arguments.parse_args()
        else:
            parsed_args = arguments.parse_args(args)
        self.exit_code = 0
        with self.handling_exceptions():
            self.use_args(parsed_args, interact, original_args=args)
        self.exit_on_error()
666833
def exit(self, message):
        

        self.output(message, normal=True, color="green")
        sys.exit()
805653
def safe_main():
    """"""
    try:
        main()
    except KeyboardInterrupt:
        logger.info("Cancelled by user")
        sys.exit(0)
    except ProgramError as e:
        logger.error(e.message)
        parser.error(e.message)
1008141
def _bind_exit_key(self, key):
        """
        keyinfo = make_KeyPress_from_keydescr(key.lower()).tuple()
        self.exit_dispatch[keyinfo] = None
999696
def clean_exit(signum, frame=None):
    
    global exiting
    if exiting:
        # Since this is set up as a handler for SIGCHLD when this kills one
        # child it gets another signal, the global exiting avoids this running
        # multiple times.
        LOG.debug('Exit in progress clean_exit received additional signal %s' % signum)
        return

    LOG.info('Received signal %s, beginning graceful shutdown.' % signum)
    exiting = True
    wait_for_exit = False

    for process in processors:
        try:
            if process.is_alive():
                # Sends sigterm which any processes after a notification is sent attempt to handle
                process.terminate()
                wait_for_exit = True
        except Exception:  # nosec
            # There is really nothing to do if the kill fails, so just go on.
            # The # nosec keeps bandit from reporting this as a security issue
            pass

    # wait for a couple seconds to give the subprocesses a chance to shut down correctly.
    if wait_for_exit:
        time.sleep(2)

    # Kill everything, that didn't already die
    for child in multiprocessing.active_children():
        LOG.debug('Killing pid %s' % child.pid)
        try:
            os.kill(child.pid, signal.SIGKILL)
        except Exception:  # nosec
            # There is really nothing to do if the kill fails, so just go on.
            # The # nosec keeps bandit from reporting this as a security issue
            pass

    if signum == signal.SIGTERM:
        sys.exit(0)

    sys.exit(signum)
657017
def add_exit(self):
        
        self.completable.append("quit")
        self.completable.append("exit")

        self.descrip["quit"] = "Exits the program"
        self.descrip["exit"] = "Exits the program"

        self.command_tree.add_child(CommandBranch("quit"))
        self.command_tree.add_child(CommandBranch("exit"))

        self.command_param["quit"] = ""
        self.command_param["exit"] = ""
874472
def logout (self):
        '''
        '''
        self.sendline("exit")
        index = self.expect([EOF, "(?i)there are stopped jobs"])
        if index==1:
            self.sendline("exit")
            self.expect(EOF)
        self.close()