add windows exit code support

This commit is contained in:
crazywhalecc 2022-08-22 21:32:00 +08:00
parent 6f30c04899
commit 05ac2feebd
2 changed files with 3 additions and 6 deletions

View File

@ -37,10 +37,7 @@ ob_event_provider()->addEventListener(WorkerStartEvent::getName(), function () {
} finally { } finally {
global $_swoole_atomic; global $_swoole_atomic;
$_swoole_atomic->set($retcode ?? 0); $_swoole_atomic->set($retcode ?? 0);
if (DIRECTORY_SEPARATOR === '\\') { Framework::getInstance()->stop($retcode ?? 0);
exit($retcode ?? 0);
}
Framework::getInstance()->stop();
} }
}, 1); }, 1);

View File

@ -109,7 +109,7 @@ class Framework
* 未测试 * 未测试
* @throws ZMKnownException * @throws ZMKnownException
*/ */
public function stop() public function stop(int $retcode = 0)
{ {
switch ($this->driver->getName()) { switch ($this->driver->getName()) {
case 'swoole': case 'swoole':
@ -120,7 +120,7 @@ class Framework
if (extension_loaded('posix')) { if (extension_loaded('posix')) {
posix_kill(ProcessStateManager::getProcessState(ZM_PROCESS_MASTER)['pid'], SIGTERM); posix_kill(ProcessStateManager::getProcessState(ZM_PROCESS_MASTER)['pid'], SIGTERM);
} else { } else {
Worker::stopAll(); Worker::stopAll($retcode);
} }
break; break;
} }