Notify the termination of a process.

        @type  event: L{ExitProcessEvent}
        @param event: Exit process event.

        @rtype:  bool
        @return: C{True} to call the user-defined handler, C{False} otherwise.
189915
def _notify_exit_process(self, event):
        
        self.__cleanup_process(event)
        self.__cleanup_thread(event)
        return True
62114
def on_event(self, event):
        
        self._queue.append((event))
        if not self._active and self.plot.document:
            self.plot.document.add_timeout_callback(self.process_on_event, 50)
            self._active = True
93550
def _terminate(self, level: int) -> bool:
        
        if not self.running:
            return True

        # Already closed by itself?
        try:
            self.wait(0)
            return True
        except subprocess.TimeoutExpired:  # failed to close
            pass

        # SEE NOTES ABOVE. This is tricky under Windows.

        suffix = " [to child process {}]".format(self.process.pid)
        if level == self.KILL_LEVEL_CTRL_C_OR_SOFT_KILL:
            if WINDOWS:
                success = 0 != ctypes.windll.kernel32.GenerateConsoleCtrlEvent(
                    CTRL_C_EVENT, self.process.pid)
                if success:
                    self.info("Sent CTRL-C to request stop" + suffix)
                    # ... but that doesn't mean it'll stop...
                else:
                    self.info("Failed to send CTRL-C" + suffix)
                return success
            else:
                self.warning("Asking process to stop (SIGTERM)" + suffix)
                self.process.terminate()  # soft kill under POSIX
                return True

        elif level == self.KILL_LEVEL_CTRL_BREAK:
            if not WINDOWS:
                return False
            success = 0 != ctypes.windll.kernel32.GenerateConsoleCtrlEvent(
                CTRL_BREAK_EVENT, self.process.pid)
            if success:
                self.info("Sent CTRL-BREAK to request stop" + suffix)
            else:
                self.info("Failed to send CTRL-BREAK" + suffix)
            return success

        elif level == self.KILL_LEVEL_TASKKILL:
            if not WINDOWS:
                return False
            retcode = self._taskkill(force=False)  # does its own info messages
            return retcode == winerror.ERROR_SUCCESS

        elif level == self.KILL_LEVEL_TASKKILL_FORCE:
            if not WINDOWS:
                return False
            retcode = self._taskkill(force=True)  # does its own info messages
            return retcode == winerror.ERROR_SUCCESS

        elif level == self.KILL_LEVEL_HARD_KILL:
            # Last resort
            self._kill()  # may do TASKKILL /F or some other method
            return True

        else:
            raise ValueError("Bad kill level requested")
524568
function ExitHandler( exiting, error ) {
	if( error ) {
		if( error.stack ) {
			console.error( error.stack );
		}

		process.exit( 1 );
	}

	if( exiting.now ) {
		process.exit( 0 ); // exit now
	}

	console.log('\n');

	process.exit( 0 ); // now exit with a smile :)
}
834960
def handler(self, event):
        """"""

        if self.escape(event):  # A chance to escape
            self.stop()
        elif self.diagnostic:
            self._diagnostic(event)
        else:
            self._tap(event)
        #This is needed according to the pyHook tutorials 'http://sourceforge.net/apps/mediawiki/pyhook/index.php?title=PyHook_Tutorial'
        return True
463288
def on_terminate(func):
    """"""
    def exit_function(*args):
        func()
        exit(0)
    signal.signal(signal.SIGTERM, exit_function)
541210
def write_event(self, event):
        

        if not self.header_written:
            self._out.write("<stream>")
            self.header_written = True

        event.write_to(self._out)
1279184
def event_handler(event)
      case event.command
      when :shutdown
        shutdown_handler(event)
        @run = false
      when :perform
        perform_handler(event)
      else
        raise Workers::UnknownEventError, "Unhandled event (#{event.inspect})."
      end

      nil
    end
156451
def process_event(self, event):
        
        # Convert into absolute coordinates if needed.
        new_event = event
        if self._absolute:
            new_event.y -= self._canvas.start_line

        # Process event if needed.
        if self.is_mouse_over(new_event) and event.buttons != 0:
            self._set_pos((new_event.y - self._y) / (self._height - 1))
            return True
        return False
976349
def __exitfunction(self):
        '''
        
        '''
        if self._hook.exit_code is None and self._hook.exception is None:
            print("Check did not exit! You should call an exit code method.")
            sys.stdout.flush()
            os._exit(1)
        elif self._hook.exception:
            print("Check failed to run: %s, %s" %
                  (sys.last_type, traceback.format_tb(sys.last_traceback)))
            sys.stdout.flush()
            os._exit(2)
979923
def closeEvent( self, event ):
        
        if ( XConfigDialog._instance == self ):
            XConfigDialog._instance = None
        
        super(XConfigDialog, self).closeEvent(event)
1097242
def keyPressEvent(self, event):
        
        if self._process.state() != self._process.Running:
            return
        tc = self.textCursor()
        sel_start = tc.selectionStart()
        sel_end = tc.selectionEnd()
        tc.setPosition(self._formatter._last_cursor_pos)
        self.setTextCursor(tc)
        if self.input_handler.key_press_event(event):
            tc.setPosition(sel_start)
            tc.setPosition(sel_end, tc.KeepAnchor)
            self.setTextCursor(tc)
            super(OutputWindow, self).keyPressEvent(event)
        self._formatter._last_cursor_pos = self.textCursor().position()
1027276
def eventloop(self, *args, **kwargs):
        

        # Setting status
        status = None

        # Starting the clock
        start = time.time()

        first_loop = True
        # loop running target, maybe more than once
        while not self.exit.is_set():

            if first_loop:
                first_loop = False
                # signalling startup only the first time, just after having check for exit request.
                # We need to return control before starting, but after entering context...
                self.started.set()
                # TODO : check if better outside of loop maybe ??
                # It will change semantics, but might be more intuitive...

            # time is ticking
            # TODO : move this out of here. this class should require only generic interface to any method.
            now = time.time()
            timedelta = now - start
            start = now

            # replacing the original Process.run() call, passing arguments to our target
            if self._target:
                # bwcompat
                kwargs['timedelta'] = timedelta

                # TODO : use return code to determine when/how we need to run this the next time...
                # Also we need to keep the exit status to be able to call external process as an update...

                logging.debug(
                    "[{self.name}] calling {self._target.__name__} with args {args} and kwargs {kwargs}...".format(
                        **locals()))
                status = self._target(*args, **kwargs)

            if status is not None:
                break

        if self.started.is_set() and status is None and self.exit.is_set():
            # in the not so special case where we started, we didnt get exit code and we exited,
            # this is expected as a normal result and we set an exitcode here of 0
            # As 0 is the conventional success for unix process successful run
            status = 0

        return status
591266
def dispatch_event(self, event, *args):
        
        if event not in self.event_handlers:
            _log.error("Dispatch requested for unknown event '%s'", event)
            return False
        elif event != "LINE":
            _log.debug("Dispatching event %s %r", event, args)

        try:
            for handler in self.event_handlers[event]:
                # (client, server, *args) : args are dependent on event
                if handler(self, *args):
                    # Returning a truthy value supresses further handlers
                    # for this event.
                    return True
        except Exception as e:
            _log.exception("Error while processing event '%s': %r", event, e)

        # Fall back to the RAWLINE event if LINE can't process it.
        if event == "LINE":
            return self.dispatch_event("RAWLINE", *args)

        return False
227109
function check() {
    if (terminated) {
      // Successfully terminated
      clearTimeout(t);
      return callback();
    }
    if ((Date.now() - start) < timeout) {
      // Still not terminated, try again
      signalTerm(childProcess, (err) => {
        if (err) { return callback(err); }
        t = setTimeout(check, retryDelay);
      });
    } else {
      // Still not terminated and the timeout has passed, either
      // kill the process (force) or provide an error
      clearTimeout(t);
      if (force) {
        signalKill(childProcess, callback);
      } else {
        callback(
          new Error(`Unable to gracefully terminate process ${childProcess.pid}`)
        );
      }
    }
  }
213727
def remove_handler(self, handler):
        
        try:
            self._events[handler.type].remove(handler)
            return True
        except ValueError:
            return False
926462
def closeEvent(self, event):
        
        logger.debug("closeEvent")
        self.argosApplication.saveSettingsIfNeeded()
        self.finalize()
        self.argosApplication.removeMainWindow(self)
        event.accept()
        logger.debug("closeEvent accepted")