An helper function there will intercept internal exit event if necessary
551612
function interceptDeath(process, events) {
    var closeEvent = helpers.support.close;

    // all channels are closed
    process.once(closeEvent ? 'close' : 'exit', events.close);

    // the process died
    if (closeEvent) {
      process.once('exit', events.exit);
    } else {

      // intercept internal onexit call
      var internalHandle = process._internal.onexit;
      process._internal.onexit = function () {
        events.exit();
        internalHandle.apply(this, arguments);
      };
    }
  }
1297082
function (args, detached, callback) {
  let error, errorEmitted, stderr, stdout

  try {
    // Ensure we don't spawn multiple squirrel processes
    // Process spawned, same args:        Attach events to alread running process
    // Process spawned, different args:   Return with error
    // No process spawned:                Spawn new process
    if (spawnedProcess && !isSameArgs(args)) {
      // Disabled for backwards compatibility:
      // eslint-disable-next-line standard/no-callback-literal
      return callback(`AutoUpdater process with arguments ${args} is already running`)
    } else if (!spawnedProcess) {
      spawnedProcess = spawn(updateExe, args, {
        detached: detached,
        windowsHide: true
      })
      spawnedArgs = args || []
    }
  } catch (error1) {
    error = error1

    // Shouldn't happen, but still guard it.
    process.nextTick(function () {
      return callback(error)
    })
    return
  }
  stdout = ''
  stderr = ''

  spawnedProcess.stdout.on('data', (data) => { stdout += data })
  spawnedProcess.stderr.on('data', (data) => { stderr += data })

  errorEmitted = false
  spawnedProcess.on('error', (error) => {
    errorEmitted = true
    callback(error)
  })

  return spawnedProcess.on('exit', function (code, signal) {
    spawnedProcess = undefined
    spawnedArgs = []

    // We may have already emitted an error.
    if (errorEmitted) {
      return
    }

    // Process terminated with error.
    if (code !== 0) {
      // Disabled for backwards compatibility:
      // eslint-disable-next-line standard/no-callback-literal
      return callback(`Command failed: ${signal != null ? signal : code}\n${stderr}`)
    }

    // Success.
    callback(null, stdout)
  })
}
823610
function() {
			this.loaded		= false;
			this.stopped	= true;

			var current = Script.current(this.loader);

			// Unbind and remove the relevant tag, if any.
			this.destroy();

			// Welcome traveller!  You've discovered the ugly truth!  This is
			// the 'magic' of the require script, allowing execution to be
			// halted until dependencies have been satisfied.  Basically it:
			//
			// * Sets up top level error handlers
			// * throws an error
			// * catches that error at the top level
			// * reverts the handling functionality back to its original state
			//
			// It is definitely not pretty, but by doing so we can halt
			// execution of a script at an arbitrary point, as long as the stack
			// does not have any `try{ ... }catch{ ... }` blocks along the way.
			var existing	= window.onerror,
				tag			= this.tag;

			function handler(event) {
				if (event.target !== window) {
					return true;
				}

				if (root.removeEventListener) {
					root.removeEventListener('error', handler, true);
				}else root.detachEvent('onerror', handler);

				window.onerror = existing;
				return Event.cancel(event);
			}

			window.onerror = handler;
			if (root.addEventListener) {
				root.addEventListener('error', handler, true);
			}else root.attachEvent('onerror', handler);

			throw STOP_EVENT;

		}
1104114
def exit_on_error(self):
        """"""
        if self.exit_code:
            if self.errmsg is not None:
                logger.show("Exiting due to " + self.errmsg + ".")
                self.errmsg = None
            if self.using_jobs:
                kill_children()
            sys.exit(self.exit_code)
913076
def cli(ctx, cmd):
    """"""

    exit_code = util.call(cmd)
    ctx.exit(exit_code)
311146
function hookChildProcEvents() {
        childProc.on('error', function (err) {
            logger.error('error: ', err);
            _childProcLastError = err;
        });
        childProc.on('disconnect', function () {
            logger.debug('script-boilerplate process disconnected');
        });
        childProc.on('uncaughtException', function (err) {
            logger.error('uncaughtException: ', (err && err.stack) ? err.stack : err);
            _childProcLastError = err;
        });
        childProc.on('exit', function (code, signal) {
            logger.debug('script-boilerplate process exited with code: ' + code + ', signal: ' + signal);
            if (dbg) {
                dbg.close();
            }
            if (code && code !== 0) {
                //logger.debug('script-boilerplate process exited with code: ' + code + ', signal: ' + signal);
                // if the test is running or is being disposed and the child process has died,
                // then finish the test or disposal with fatal error
                // (child process not suppose to die with code > 0)
                var promise, error;
                if (_isRunning || _isDisposing) {
                    promise = _isRunning ? _whenFinished : _whenDisposed;
                    error = _childProcLastError || new Error('script-boilerplate process exited with code: ' + code);
                    promise.reject(error);
                    resetGlobalVariables();
                }
            }
        });
        childProc.on('message', function (msg) {
            if (msg.event && msg.event === 'log-add') {
                if (msg.level === 'DEBUG') {
                    logger.debug(msg.msg);
                } else if (msg.level === 'INFO') {
                    logger.info(msg.msg);
                } else if (msg.level === 'ERROR') {
                    logger.error(msg.msg, msg.err);
                } else if (msg.level === 'WARN') {
                    logger.warn(msg.msg);
                }
                
                if (msg.issuer === DEFAULT_ISSUER) {
                    ee.emit('log-add', msg.level, msg.msg, msg.time);
                }
            } else if (msg.event && msg.event === 'init-success') {
                _isInitializing = false;
                _whenInitialized.resolve(null);
            } else if (msg.event && msg.event === 'init-failed') {
                _isInitializing = false;
                _whenInitialized.reject(msg.err);
            } else if (msg.event && msg.event === 'execution-ended') {
                processResultsAndRunTheNextIteration(msg);
            } else if (msg.event && msg.event === 'modules-disposed') {
                resetGlobalVariables();
                _whenDisposed.resolve(null);
            } else if (msg.event && msg.event === 'line-update') {
                ee.emit('line-update', msg.line, msg.stack, msg.time);
            } else if (msg.event && msg.event === 'result-update') {
                if (msg.method === 'init') {
                    ee.emit('init-done', msg);
                }
            }
        });
    }
615828
function () {
    const oThis = this
    ;

    oThis.snmData.lastProcessedBlock = oThis.toBlock;

    fs.writeFileSync(
      oThis.filePath,
      JSON.stringify(oThis.snmData),
      function (err) {
        if (err)
          logger.error(err);
      }
    );

    if (oThis.interruptSignalObtained) {
      logger.info('Exiting Process....');
      process.exit(1);
    }
  }
228003
function abort() {
    var event,
        me = this,
        resetting = calledBy.reset;

    if (me.running) {
      event = Event('abort');
      me.emit(event);
      if (!event.cancelled || resetting) {
        // avoid infinite recursion
        calledBy.abort = true;
        me.reset();
        delete calledBy.abort;

        if (support.timeout) {
          clearTimeout(me._timerId);
          delete me._timerId;
        }
        if (!resetting) {
          me.aborted = true;
          me.running = false;
        }
      }
    }
    return me;
  }
374223
def _leave_handler(self, event):
        """"""
        iid = self.current_iid
        if iid is None or self.active == iid:
            return
        self.update_state(iid, "normal")
1080166
function onRemove( error ) {
		if ( error ) {
			debug( 'Error encountered while attempting to delete a temporary input file %s: %s', inFile, error.message );
			return done( error );
		}
		debug( 'Successfully deleted temporary input file: %s', inFile );
		if ( dest === void 0 ) {
			debug( 'Reading temporary output file: %s', outFile );
			return readFile( outFile, {'encoding':'utf8'}, onFile );
		}
		done();
	}
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)
1045372
function(element, enterCallback, exitCallback, errorCallback) {
			if (bigscreen.element) {
				bigscreen.exit();
			}
			else {
				bigscreen.request(element, enterCallback, exitCallback, errorCallback);
			}
		}
482345
def _exit_handling(self):
        

        def close_asyncio_loop():
            loop = None
            try:
                loop = asyncio.get_event_loop()
            except AttributeError:
                pass
            if loop is not None:
                loop.close()

        atexit.register(close_asyncio_loop)
1172122
def exit(self, result=0, msg=None, *args, **kwargs):
    """"""
    if self._finalizer:
      try:
        self._finalizer()
      except Exception as e:
        try:
          NailgunProtocol.send_stderr(
            self._socket,
            '\nUnexpected exception in finalizer: {!r}\n'.format(e)
          )
        except Exception:
          pass

    try:
      # Write a final message to stderr if present.
      if msg:
        NailgunProtocol.send_stderr(self._socket, msg)

      # Send an Exit chunk with the result.
      NailgunProtocol.send_exit_with_code(self._socket, result)

      # Shutdown the connected socket.
      teardown_socket(self._socket)
    finally:
      super(DaemonExiter, self).exit(result=result, *args, **kwargs)
345069
def _exit_handler(self):
        

        # TODO: consider handling sys.stderr/sys.stdout exceptions related to
        # TODO (cont.): order of interpreter vs. subprocess shutdown signal receipt.
        # TODO (cont.): see https://bugs.python.org/issue11380


        # Make the cleanup file executable if it exists
        if os.path.isfile(self.cleanup_file):
            # Make the cleanup file self destruct.
            with open(self.cleanup_file, "a") as myfile:
                myfile.write("rm " + self.cleanup_file + "\n")
            os.chmod(self.cleanup_file, 0o755)

        # If the pipeline hasn't completed successfully, or already been marked
        # as failed, then mark it as failed now.

        if not self._has_exit_status:
            print("Pipeline status: {}".format(self.status))
            self.fail_pipeline(Exception("Pipeline failure. See details above."))

        if self.tee:
            self.tee.kill()
1360325
def signal_catcher(callback):
    """"""
    def _catch_exit_signal(sig_num, _frame):
        print('Received signal {:d} invoking callback...'.format(sig_num))
        callback()

    signal.signal(signal.SIGINT, _catch_exit_signal)
    signal.signal(signal.SIGQUIT, _catch_exit_signal)
    signal.signal(signal.SIGTERM, _catch_exit_signal)
    yield
189915
def _notify_exit_process(self, event):
        
        self.__cleanup_process(event)
        self.__cleanup_thread(event)
        return True