Previously this would exit immediately with the provided
 exit code; however this would prevent post-run hooks from continuing
 Instead, we'll just track whether a an exit was requested and use that
 to determine how we exit from 'run'
356238
def run(args)
      # Ensure Omnibus related binaries are in the PATH
      ENV["PATH"] = [File.join(base_path, "bin"),
                     File.join(base_path, "embedded","bin"),
                     ENV['PATH']].join(":")

      command_to_run = args[0]

      ## when --help is run as the command itself, we need to strip off the
      ## `--` to ensure the command maps correctly.
      if command_to_run == "--help"
        command_to_run = "help"
      end

      # This piece of code checks if the argument is an option. If it is,
      # then it sets service to nil and adds the argument into the options
      # argument. This is ugly. A better solution is having a proper parser.
      # But if we are going to implement a proper parser, we might as well
      # port this to Thor rather than reinventing Thor. For now, this preserves
      # the behavior to complain and exit with an error if one attempts to invoke
      # a pcc command that does not accept an argument. Like "help".
      options = args[2..-1] || []
      if is_option?(args[1])
        options.unshift(args[1])
        service = nil
      else
        service = args[1]
      end

      # returns either hash content of command or nil
      command = retrieve_command(command_to_run)
      if command.nil?
        log "I don't know that command."
        if args.length == 2
          log "Did you mean: #{exe_name} #{service} #{command_to_run}?"
        end
        help
        Kernel.exit 1
      end

      if args.length > 1 && command[:arity] != 2
        log "The command #{command_to_run} does not accept any arguments"
        Kernel.exit 2
      end

      parse_options options
      @force_exit = false
      exit_code = 0

      run_global_pre_hooks

      # Filter args to just command and service. If you are loading
      # custom commands and need access to the command line argument,
      # use ARGV directly.
      actual_args = [command_to_run, service].reject(&:nil?)
      if command_pre_hook(*actual_args)
        method_to_call = to_method_name(command_to_run)
        begin
          ret = send(method_to_call, *actual_args)
        rescue SystemExit => e
          @force_exit = true
          ret = e.status
        end
        command_post_hook(*actual_args)
        exit_code = ret unless ret.nil?
      else
        exit_code = 8
        @force_exit = true
      end

      if @force_exit
        Kernel.exit exit_code
      else
        exit_code
      end
    end
871090
def exit(self, exit_code):
        
        self.inhibit_autoret = True
        self.state.options.discard(o.AST_DEPS)
        self.state.options.discard(o.AUTO_REFS)

        if isinstance(exit_code, int):
            exit_code = self.state.solver.BVV(exit_code, self.state.arch.bits)
        self.state.history.add_event('terminate', exit_code=exit_code)
        self.successors.add_successor(self.state, self.state.regs.ip, self.state.solver.true, 'Ijk_Exit')
940584
def if_end_action(self, text, loc, arg):
        """"""
        exshared.setpos(loc, text)
        if DEBUG > 0:
            print("IF_END:",arg)
            if DEBUG == 2: self.symtab.display()
            if DEBUG > 2: return
        self.codegen.newline_label("exit{0}".format(self.label_stack.pop()), True, True)
927964
def fast_exit(code):
    
    sys.stdout.flush()
    sys.stderr.flush()
    os._exit(code)
630041
def update_exit_code(self, code: int):
        '''
        '''
        if code:
            if self._exit_code:
                self._exit_code = min(self._exit_code, code)
            else:
                self._exit_code = code
1036011
def exitcode(self):
        
        if self._process is None:
            raise ProcessError(
                "Process '%s' has not been started yet" % self.name)
        return self._process.exitcode
971104
def post_run_hook(self, func, prefix=None):
        
        cf = self.capture(func, prefix=prefix)
        self.post_run_hooks.append(cf)
        return cf
46574
def handle_process_exit_code(exit_code):
    
    # if we exited from a signal, let our exit code reflect that
    if os.WIFSIGNALED(exit_code):
        exit_code = -os.WTERMSIG(exit_code)
    # otherwise just give us a normal exit code
    elif os.WIFEXITED(exit_code):
        exit_code = os.WEXITSTATUS(exit_code)
    else:
        raise RuntimeError("Unknown child exit status!")

    return exit_code
1253269
def do_exit(*args):
    '''
        
    '''

    try:
        import java.lang.System

        java.lang.System.exit(1)
    except ImportError:
        if len(args) == 1:
            os._exit(args[0])
        else:
            os._exit(0)
974433
function runHooks(hooks, args, callback) {
    console.log('*** git-hooks.js runHooks', hooks, args);
    if (!hooks.length) {
        callback(0);
        return;
    }
    try {
        var hook = spawnHook(hooks.shift(), args);
        hook.on('close', function (code) {
            if (code === 0) {
                runHooks(hooks, args, callback);
            } else {
                callback(code);
            }
        });
    } catch (e) {
        callback(1, e);
    }
}
1048891
def exit(self, code=0, message=None):
        

        ## If we have a parser, use it to exit
        if self._parser:
            if code > 0:
                self.parser.error(message)
            else:
                self.parser.exit(code, message)

        ## Else we are exiting before parser creation
        else:
            if message is not None:
                if code > 0:
                    sys.stderr.write(message)
                else:
                    sys.stdout.write(message)
            sys.exit(code)

        ## If we're here we didn't exit for some reason?
        raise Exception("Unable to exit the %s" % self.__class__.__name__)
1339968
def background_thread(timeout_fn, timeout_event, handle_exit_code, is_alive,
        quit):
    

    # if there's a timeout event, loop 
    if timeout_event:
        while not quit.is_set():
            timed_out = event_wait(timeout_event, 0.1)
            if timed_out:
                timeout_fn()
                break

    # handle_exit_code will be a function ONLY if our command was NOT waited on
    # as part of its spawning.  in other words, it's probably a background
    # command
    #
    # this reports the exit code exception in our thread.  it's purely for the
    # user's awareness, and cannot be caught or used in any way, so it's ok to
    # suppress this during the tests
    if handle_exit_code and not RUNNING_TESTS: # pragma: no cover
        alive = True
        while alive:
            quit.wait(1)
            alive, exit_code = is_alive()

        handle_exit_code(exit_code)
716838
@VisibleForTesting
  void exitIdleMode() {
    syncContext.throwIfNotInThisSynchronizationContext();
    if (shutdown.get() || panicMode) {
      return;
    }
    if (inUseStateAggregator.isInUse()) {
      // Cancel the timer now, so that a racing due timer will not put Channel on idleness
      // when the caller of exitIdleMode() is about to use the returned loadBalancer.
      cancelIdleTimer(false);
    } else {
      // exitIdleMode() may be called outside of inUseStateAggregator.handleNotInUse() while
      // isInUse() == false, in which case we still need to schedule the timer.
      rescheduleIdleTimer();
    }
    if (lbHelper != null) {
      return;
    }
    channelLogger.log(ChannelLogLevel.INFO, "Exiting idle mode");
    LbHelperImpl lbHelper = new LbHelperImpl();
    lbHelper.lb = loadBalancerFactory.newLoadBalancer(lbHelper);
    // Delay setting lbHelper until fully initialized, since loadBalancerFactory is user code and
    // may throw. We don't want to confuse our state, even if we will enter panic mode.
    this.lbHelper = lbHelper;

    NameResolverObserver observer = new NameResolverObserver(lbHelper, nameResolver);
    nameResolver.start(observer);
    nameResolverStarted = true;
  }
1232521
def exit_code(self) -> Any:
        
        if self._done() or self.is_killed():
            return self._exit_code
        else:
            raise BehaviourNotFinishedException
189915
def _notify_exit_process(self, event):
        
        self.__cleanup_process(event)
        self.__cleanup_thread(event)
        return True
502766
def exit(exit_code=0):
    

    for line in SESSION_FOOTER_TEXT:
        LOGGER.info(line)

    foundations.verbose.remove_logging_handler(RuntimeGlobals.logging_console_handler)

    RuntimeGlobals.application.exit(exit_code)
398764
private static void runHooks() {
        for (int i=0; i < MAX_SYSTEM_HOOKS; i++) {
            try {
                Runnable hook;
                synchronized (lock) {
                    // acquire the lock to make sure the hook registered during
                    // shutdown is visible here.
                    currentRunningHook = i;
                    hook = hooks[i];
                }
                if (hook != null) hook.run();
            } catch(Throwable t) {
                if (t instanceof ThreadDeath) {
                    ThreadDeath td = (ThreadDeath)t;
                    throw td;
                }
            }
        }
    }