监控正在运行的播放器（独立线程）

        播放器退出后将会设置 _exit_event
196535
def _watchdog(self):
        
        if not self.is_alive:
            logger.debug("Player has already terminated.")
            self._exit_event.set()
            return
        logger.debug("Watching %s[%d]",
                     self._player_command, self.sub_proc.pid)
        returncode = self.sub_proc.wait()
        logger.debug("%s[%d] exit with code %d",
                     self._player_command, self.sub_proc.pid, returncode)
        self._exit_event.set()
1018887
function end () {
      sent = true;
      // next tick it to avoid express catching runtime error in the callback
      //   getting caught by express and triggering app's error handler
      process.nextTick(function () {
        res.emit('finish');
        cb(null, res);
      });
    }
1334446
function eventHandler(event, handler, scope) {
  let modifiersMatch;

  // 看它是否在当前范围
  if (handler.scope === scope || handler.scope === 'all') {
    // 检查是否匹配修饰符（如果有返回true）
    modifiersMatch = handler.mods.length > 0;

    for (const y in _mods) {
      if (Object.prototype.hasOwnProperty.call(_mods, y)) {
        if (
          (!_mods[y] && handler.mods.indexOf(+y) > -1) ||
          (_mods[y] && handler.mods.indexOf(+y) === -1)
        ) modifiersMatch = false;
      }
    }

    // 调用处理程序，如果是修饰键不做处理
    if (
      (handler.mods.length === 0 && !_mods[16] && !_mods[18] && !_mods[17] && !_mods[91]) ||
      modifiersMatch ||
      handler.shortcut === '*'
    ) {
      if (handler.method(event, handler) === false) {
        if (event.preventDefault) event.preventDefault();
        else event.returnValue = false;
        if (event.stopPropagation) event.stopPropagation();
        if (event.cancelBubble) event.cancelBubble = true;
      }
    }
  }
}
110665
def exit(status=0):
    
    if status == 0:
        lab.io.printf(lab.io.Colours.GREEN, "Done.")
    else:
        lab.io.printf(lab.io.Colours.RED, "Error {0}".format(status))
    sys.exit(status)
91478
function shutdown()
	{
	    //关闭服务器端
	    sw_socket_close($this->server_sock,$this->server_event);
	    //关闭事件循环
        event_base_loopexit($this->base_event);
        $this->protocol->onShutdown();
	}
203928
function(err, exit) {
    // Close the terminal
    if(terminal) terminal.close()

    // If there was an error throw it before exit
    if(err) throw err

    // process.stdin.resume() prevents node from exiting.
    // process.exit() overrides in more cases than stdin.pause() or stdin.end()
    // it also means we don't need to call process.stdin.setRawMode(false)
    if(exit === undefined || exit) {
      process.exit()
    }
    else {
      process.stdin.setRawMode(false)
      process.stdin.end()
    }
  }
844338
function() {
			if(index < count) {
				inspectors[index++].inspect(this); // 执行递归，进行下一轮检查
			} else if(index++ === count) {
				ctrler.execute(); // 当inspector 被执行完时，执行 controller
				end();
			}
		}
151056
public function onSwooleWorkerError($serv, $worker_id, $worker_pid, $exit_code)
    {
        $data = ['worker_id' => $worker_id,
            'worker_pid' => $worker_pid,
            'exit_code' => $exit_code];
        $log = "WORKER Error ";
        $log .= json_encode($data);
        $this->log->alert($log);
        if ($this->onErrorHandel != null) {
            sd_call_user_func($this->onErrorHandel, '【！！！】服务器进程异常退出', $log);
        }
    }
1171363
def exit_after(s):
    

    def outer(fn):
        def inner(*args, **kwargs):
            timer = threading.Timer(s, thread.interrupt_main)
            timer.start()
            try:
                result = fn(*args, **kwargs)
            except KeyboardInterrupt:
                raise TimeoutError("Function '{}' hit the timeout ({}s).".format(fn.__name__, s))
            finally:
                timer.cancel()
            return result

        return inner

    return outer
527084
private void checkEnd() {
    if (ended && !closed && children == 0) {
      closed = true;
      connection.doBatchEnd(id, endArgs);
      if (endHandler != null) {
        endHandler.handle((Void) null);
      }
    }
  }
72287
function exit(inst, state, fin) {
    return fin(_wrapError(_outOfGasError(inst), inst, state), state);
}
314723
static void exitWithError(Boolean isDebug, Exception e) {
        System.err.println("Error executing function (Use -x for more information): " + e.getMessage());
        if (isDebug) {
            System.err.println();
            System.err.println("Error Detail");
            System.err.println("------------");
            e.printStackTrace(System.err);
        }
        System.exit(1);
    }
1318524
function _check(asyncClient, route) {
    return new Promise((resolve, reject) => {
        // 有问题时直接执行真实的fetch方法
        if (!asyncClient) {
            return reject(RESULT.NO_ASYNC_CLIENT);
        }

        // 如果远程服务未启动也需要放弃async
        if (!route) {
            return reject(RESULT.NO_ROUTE);
        }

        let i = 0;
        let checkT;

        function checkConnect() {
            if (asyncClient.isConnected()) {
                // 如果已经连接成功，则清除定时器，并返回
                if (checkT) {
                    clearTimeout(checkT);
                }

                resolve();
            } else if (i > 9) {
                // 如果重试次数大于了10次，也终止，清除定时器，并返回
                if (checkT) {
                    clearTimeout(checkT);
                }

                alert(`mockstar async 服务未启动！请检查 ${asyncClient.getURI()} 是否已启动`);
                reject(RESULT.NOT_CONNECTED);
            } else {
                i++;
                // 使之异步，避免 websocket 还未连接成功
                checkT = setTimeout(() => {
                    checkConnect();
                }, 10);
            }
        }

        checkConnect();
    });
}
129244
function loop(){
  child = spawn(process.argv[0], ['server.js'], {
    detached: true,
    cwd:__dirname,
    stdio: 'inherit'
  });

  child.on('close', (code) => {
    if(code !== 0){
      execSync('cat ' + ERROR_LOG_PATH + ' > ' + ERROR_LOG_PATH + '.bak'); //error 备份.
      execSync('cat /dev/null > ' + ERROR_LOG_PATH); //清空 error log.
      handleChildCrash();
    }else{
      _colorLog('green', `[Watcher] Child exit success! Watcher exit. \t ${new Date()}`);
      execSync('rm -rf ' + PORT);
      execSync('rm -rf  ' + ERROR_LOG_PATH); //清空 error log.
      execSync('rm -rf  ' + ERROR_LOG_PATH + '.bak'); //清空 error log 备份.
      process.exit(); // 正常退出
    }
  });
}
914393
function debounce (func, threshold) {
  var timeout;
  return function debounced () {
    var obj = this, args = arguments;
    function delayed () {
      // 让调用smartresize的对象执行
      func.apply(obj, args);
      /*
      timeout = null;：这个语句只是单纯将timeout指向null，
      而timeout指向的定时器还存在，
      要想清除定时器（让setTimeout调用的函数不执行）要用clearTimeout(timeout)。
      eg：
      var timeout = setTimeout(function(){
        alert('timeout = null');// 执行
      },1000);
      timeout = null;
      var timeout = setTimeout(function(){
        alert('clearTimeout(timeout)');// 不执行
      },1000);
      clearTimeout(timeout);
      var timeout = setTimeout(function(){
        clearTimeout(timeout);
        alert('clearTimeout(timeout)');// 执行（已经开始执行匿名函数了）
      },1000);
      */ 
      timeout = null; 
    }
    // 如果有timeout正在倒计时，则清除当前timeout
    timeout && clearTimeout(timeout);
    timeout = setTimeout(delayed, threshold || 100); 
  };
}
555659
def p_exit(p):
    
    q = p[2]
    p[0] = make_sentence('EXIT_%s' % q)

    for i in gl.LOOPS:
        if q == i[0]:
            return

    syntax_error(p.lineno(1), 'Syntax Error: EXIT %s out of loop' % q)
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 :)
}