From f8e15d2267fc8842d65b393fe0c7c1edb083ed89 Mon Sep 17 00:00:00 2001 From: Guillaume ARM Date: Sun, 14 Jun 2026 23:15:34 +0200 Subject: [PATCH] fix: better handle os shutdown in eventloop and startup/servers.lua --- apis/eventloop.lua | 2 +- manifest.json | 2 +- packages/index.json | 6 +++--- packages/trapos-boot/ccpm.json | 2 +- packages/trapos-core/ccpm.json | 2 +- packages/trapos/ccpm.json | 2 +- startup/servers.lua | 5 ++++- 7 files changed, 12 insertions(+), 9 deletions(-) diff --git a/apis/eventloop.lua b/apis/eventloop.lua index 88c9a46..5377d19 100644 --- a/apis/eventloop.lua +++ b/apis/eventloop.lua @@ -300,7 +300,7 @@ local function createEventLoop() flushUnregisterQueue() end - if eventName == END_OF_LOOP or eventName == 'terminate' then + if eventName == END_OF_LOOP or (shouldCheckHandlers and eventName == 'terminate') then execOnStopHandlers() resetAll() break diff --git a/manifest.json b/manifest.json index dca4542..ba01cec 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "TrapOS", - "version": "0.9.2", + "version": "0.9.3", "branch": "next", "packages": [ "trapos" diff --git a/packages/index.json b/packages/index.json index e4c3624..e282efd 100644 --- a/packages/index.json +++ b/packages/index.json @@ -1,13 +1,13 @@ { "packages": { - "trapos-core": "0.5.0", + "trapos-core": "0.5.1", "trapos-test": "0.2.1", - "trapos-boot": "0.3.2", + "trapos-boot": "0.3.3", "trapos-net": "0.3.0", "trapos-ui": "0.2.2", "trapos-ai": "0.7.0", "trapos-sandbox": "0.2.5", "trapos-sandbox-legacy": "0.2.2", - "trapos": "0.9.2" + "trapos": "0.9.3" } } diff --git a/packages/trapos-boot/ccpm.json b/packages/trapos-boot/ccpm.json index 247bc16..9a0463c 100644 --- a/packages/trapos-boot/ccpm.json +++ b/packages/trapos-boot/ccpm.json @@ -1,6 +1,6 @@ { "name": "trapos-boot", - "version": "0.3.2", + "version": "0.3.3", "description": "TrapOS boot: startup MOTD and autostart server launcher", "dependencies": ["trapos-core"], "files": [ diff --git a/packages/trapos-core/ccpm.json b/packages/trapos-core/ccpm.json index ace6815..f1a267a 100644 --- a/packages/trapos-core/ccpm.json +++ b/packages/trapos-core/ccpm.json @@ -1,6 +1,6 @@ { "name": "trapos-core", - "version": "0.5.0", + "version": "0.5.1", "description": "TrapOS base: package manager, event loop, upgrade and event tools", "dependencies": [], "files": [ diff --git a/packages/trapos/ccpm.json b/packages/trapos/ccpm.json index a1bec8f..d5cf4eb 100644 --- a/packages/trapos/ccpm.json +++ b/packages/trapos/ccpm.json @@ -1,6 +1,6 @@ { "name": "trapos", - "version": "0.9.2", + "version": "0.9.3", "description": "TrapOS full install meta-package", "dependencies": [ "trapos-boot", diff --git a/startup/servers.lua b/startup/servers.lua index 5a5e11c..556e802 100644 --- a/startup/servers.lua +++ b/startup/servers.lua @@ -37,9 +37,12 @@ end _G.bootEventLoop = createEventLoop() +local shellExited = false + local function shellFn() os.sleep(0.1) shell.run("shell") + shellExited = true end local function eventLoopFn() @@ -62,6 +65,6 @@ end parallel.waitForAny(shellFn, eventLoopFn) -if shouldShutdownOnShellExit() then +if shellExited and shouldShutdownOnShellExit() then os.shutdown() end