This is the default shutdown callback that is set on the options.
    It prints out a message to stderr that informs the user that some events
    are still pending and the process is waiting for them to flush out.
771609
def default_callback(pending, timeout):
    

    def echo(msg):
        sys.stderr.write(msg + "\n")

    echo("Sentry is attempting to send %i pending error messages" % pending)
    echo("Waiting up to %s seconds" % timeout)
    echo("Press Ctrl-%s to quit" % (os.name == "nt" and "Break" or "C"))
    sys.stderr.flush()
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()
374635
def stop_process(parser_args):
    
    from synergy.system import process_helper

    try:
        pid = process_helper.get_process_pid(parser_args.process_name)
        if pid is None or process_helper.poll_process(parser_args.process_name) is False:
            message = 'ERROR: Process {0} is already terminated {1}\n'.format(parser_args.process_name, pid)
            sys.stderr.write(message)
            sys.exit(1)

        process_helper.kill_process(parser_args.process_name)
    except Exception as e:
        sys.stderr.write('Exception on killing {0} : {1}\n'.format(parser_args.process_name, e))
        traceback.print_exc(file=sys.stderr)
1209478
function execCallback(err, stream) {
    if (err) throw err;
    stream
        .on('close', function (code, signal) { console.log('Stream closed with code ' + code + ' and signal ' + signal); conn.end() })
        .on('data', function (data) { console.log(data); })
        .stderr.on('data', function (err) { console.log('!!!!!!!!!!!!!! Error: ' + err); });
}
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 :)
}
626219
function gracefulShutdown(){
  console.log('About to exit, closing servers.');

  servers.forEach(function(server, index){
    server.close();
  });

  process.exit();
}
136545
def stderr(msg, silent=False):
    
    if not silent:
        print(msg, file=sys.stderr)
879186
def check_call_no_output(args):
    
    logger = logging.getLogger(__name__)
    logger.debug("running %s", args)
    process = subprocess.Popen(
        args,
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
    )
    (res_stdout, res_stderr) = process.communicate()
    if process.returncode:
        res_stdout = res_stdout
        res_stderr = res_stderr
        print(res_stdout, end='')
        print(res_stderr, end='')
        raise ValueError('exit code from [{}] was [{}]'.format(" ".join(args), process.returncode))
228845
def shutdown(self):
        ''' 
        '''
        logging.info('Shutdown procedures being run!')
        for func in self.shutdown_cleanup.values():
            func()
        session_time = round((time.time() - self.start_time)/60, 0)
        logging.info('session time: {0} minutes'.format(session_time))
        logging.info('End..')
1222297
def _termination_callback(self, process_name, returncode):
        

        self._terminate_process_iou()
        if returncode != 0:
            if returncode == -11:
                message = 'IOU VM "{}" process has stopped with return code: {} (segfault). This could be an issue with the IOU image, using a different image may fix this.\n{}'.format(self.name,
                                                                                                                                                                                         returncode,
                                                                                                                                                                                         self.read_iou_stdout())
            else:
                message = 'IOU VM "{}" process has stopped with return code: {}\n{}'.format(self.name, returncode, self.read_iou_stdout())
            log.warning(message)
            self.project.emit("log.error", {"message": message})
        if self._telnet_server:
            self._telnet_server.close()
            self._telnet_server = None
710156
function() {
        if (this._isShuttingDown) {
            return;
        }
        this._isShuttingDown = true;

        // Restart but wait a bit to log things.
        // -R - restart
        // -C - shutdown message
        // -T 0 - shutdown now
        // -F - don't wait for anything to shut down gracefully
        var winCmd = 'shutdown -R -T 0 -F -C "ampm restart"';
        var macCmd = 'shutdown -r now';
        var cmd = process.platform === 'win32' ? winCmd : macCmd;
        setTimeout(child_process.exec(cmd), 3000);
    }
951796
public function processRecoverCallback()
    {
        while (($pid = pcntl_waitpid(0, $status, WNOHANG)) > 0) {
            $message = "process exit. pid:" . $pid . ". exit code:" . $status;
            $this->logger->info($message);
        }
    }
945601
public void shutdown() {
        shutdownCalled = true;
        if (isRunning()) {
            watchdog.waitForProcessStarted();
            watchdog.destroyProcess();
            watchdog.waitForTerminationAfterDestroy(2, SECONDS);
            if (isRunning()) {
                watchdog.destroyProcessForcefully();
                watchdog.waitForTerminationAfterDestroy(1, SECONDS);
                if (isRunning()) {
                    LOGGER.severe(String.format("Unable to kill process with PID %s", watchdog.getProcessId()));
                }
            }
        }

        // if shutdown() was called by something other than the shutdown hook, we don't need the shutdown hook anymore
        try {
            if (shutDownHook != null) {
                Runtime.getRuntime().removeShutdownHook(shutDownHook);
            }
        } catch (IllegalStateException e) {
            // ignore.. happens when the shutdown hook is in use, that's okay
        }

    }
77343
public function shutdownHandler()
    {
        $error = error_get_last();

        if (isset($error['type']) && in_array($error['type'], $this->getFatalErrorTypes())) {
            $this->log('php_shutdown', $error, 'danger', false);
        }
    }
1113643
public static function shutdown()
    {
        if (defined('__TIMER_OUT_FILE__')) {
            $strTimerOutput = Timer::varDump(false);
            if ($strTimerOutput) {
                file_put_contents(__TIMER_OUT_FILE__, $strTimerOutput . "\n", FILE_APPEND);
            }
        }

        $error = error_get_last();
        if ($error &&
            is_array($error) &&
            (!defined('\CodeGen::DebugMode') || \CodeGen::DebugMode)
        ) { // if we are codegenning, only error if we are in debug mode. Prevents chmod error.

            QcubedHandleError(
                $error['type'],
                $error['message'],
                $error['file'],
                $error['line'],
                ''
            );
        }
        //flush();	// required for hhvm
        //error_log("Flushed");
    }
873572
void waitForExit()
  {
    Runtime runtime = Runtime.getRuntime();

    ShutdownSystem shutdown = _resinSystem.getSystem(ShutdownSystem.class);

    if (shutdown == null) {
      throw new IllegalStateException(L.l("'{0}' requires an active {1}",
                                          this,
                                          ShutdownSystem.class.getSimpleName()));
    }

    /*
     * If the server has a parent process watching over us, close
     * gracefully when the parent dies.
     */
    while (! _server.isClosing()) {
      try {
        Thread.sleep(10);

        if (! checkMemory(runtime)) {
          shutdown.shutdown(ShutdownModeAmp.IMMEDIATE,
                            ExitCode.MEMORY,
                            "Server shutdown from out of memory");
          // dumpHeapOnExit();
          return;
        }

        if (! checkFileDescriptor()) {
          shutdown.shutdown(ShutdownModeAmp.IMMEDIATE,
                            ExitCode.MEMORY,
                            "Server shutdown from out of file descriptors");
          //dumpHeapOnExit();
          return;
        }

        synchronized (this) {
          wait(10000);
        }
      } catch (OutOfMemoryError e) {
        String msg = "Server shutdown from out of memory";

        ShutdownSystem.shutdownOutOfMemory(msg);
      } catch (Throwable e) {
        log.log(Level.WARNING, e.toString(), e);

        return;
      }
    }
  }
191794
function end () {
          console.log('\n=== REG DUMP ===\n' + cpu.regdump().join('\n'))
          if (options.memDump) console.log('\n\n=== MEM DUMP ===\n' + cpu.memdump(0, 65535).join('\n'))
          process.exit() // workaround for stdin event listener hanging
        }