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 {
global $_swoole_atomic;
$_swoole_atomic->set($retcode ?? 0);
if (DIRECTORY_SEPARATOR === '\\') {
exit($retcode ?? 0);
}
Framework::getInstance()->stop();
Framework::getInstance()->stop($retcode ?? 0);
}
}, 1);

View File

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