add app.is_instance_alive & rename app.terminate to app.terminate_instance

This commit is contained in:
MihailRis 2026-08-02 18:32:54 +03:00
parent 466f515ea9
commit 6bbc78098d
3 changed files with 19 additions and 3 deletions

View file

@ -425,7 +425,16 @@ static int l_start_background_instance(lua::State* L) {
return lua::pushinteger(L, handle);
}
static int l_terminate(lua::State* L) {
static int l_is_instance_alive(lua::State* L) {
int handle = lua::tointeger(L, 1);
if (handle < 0 || handle >= ::processes.size()) {
throw std::runtime_error("invalid process handle");
}
auto& process = ::processes[handle];
return lua::pushboolean(L, process && process->isActive());
}
static int l_terminate_instance(lua::State* L) {
int handle = lua::tointeger(L, 1);
if (handle < 0 || handle >= ::processes.size()) {
throw std::runtime_error("invalid process handle");
@ -472,6 +481,7 @@ const luaL_Reg applib[] = {
{"create_memory_device", lua::wrap<l_create_memory_device>},
{"start_debug_instance", lua::wrap<l_start_debug_instance>},
{"start_background_instance", lua::wrap<l_start_background_instance>},
{"terminate", lua::wrap<l_terminate>},
{"is_instance_alive", lua::wrap<l_is_instance_alive>},
{"terminate_instance", lua::wrap<l_terminate_instance>},
{nullptr, nullptr}
};