mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 10:31:50 +00:00
update sub-instance lifetime
This commit is contained in:
parent
ee9b2ab266
commit
5a8fd3ceab
4 changed files with 12 additions and 5 deletions
|
|
@ -413,6 +413,7 @@ void Engine::onWorldClosed() {
|
|||
}
|
||||
|
||||
void Engine::quit() {
|
||||
logger.info() << "quitSignal set to true";
|
||||
quitSignal = true;
|
||||
if (!isHeadless()) {
|
||||
window->setShouldClose(true);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,10 @@
|
|||
|
||||
using namespace scripting;
|
||||
|
||||
namespace {
|
||||
static std::unique_ptr<Process> sub_instance = nullptr;
|
||||
}
|
||||
|
||||
/// @brief Check if content is loaded
|
||||
static int l_is_content_loaded(lua::State* L) {
|
||||
return lua::pushboolean(L, content != nullptr);
|
||||
|
|
@ -377,7 +381,7 @@ static int l_start_background_instance(lua::State* L) {
|
|||
const auto& paths = engine->getPaths();
|
||||
|
||||
std::vector<std::string> args {
|
||||
"--headless",
|
||||
// "--headless",
|
||||
"--res", paths.getResourcesFolder().u8string(),
|
||||
"--dir", paths.getUserFilesFolder().u8string(),
|
||||
"--script", io::resolve(scriptPath).u8string(),
|
||||
|
|
@ -385,7 +389,7 @@ static int l_start_background_instance(lua::State* L) {
|
|||
args.emplace_back("--project");
|
||||
args.emplace_back(io::resolve(engine->getProject().path).u8string());
|
||||
|
||||
platform::new_engine_instance(
|
||||
::sub_instance = platform::new_engine_instance(
|
||||
std::move(args),
|
||||
outputPath.empty() ? "" : io::resolve(outputPath),
|
||||
true
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
static debug::Logger logger("main");
|
||||
|
||||
static void sigterm_handler(int signum) {
|
||||
logger.info() << "SIGTERM received";
|
||||
logger.info() << "SIGTERM received " << signum;
|
||||
Engine::getInstance().quit();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -296,7 +296,8 @@ public:
|
|||
|
||||
void terminate() final override {
|
||||
#ifdef __linux__
|
||||
kill(pid, SIGKILL);
|
||||
logger.info() << "terminating " << pid;
|
||||
kill(pid, SIGTERM);
|
||||
#elif defined(_WIN32)
|
||||
if (processHandle != nullptr) {
|
||||
TerminateProcess(processHandle, 1);
|
||||
|
|
@ -461,10 +462,11 @@ std::unique_ptr<Process> platform::new_engine_instance(
|
|||
_exit(127);
|
||||
} else {
|
||||
close(fd);
|
||||
usleep(1000); // waiting for execvp call
|
||||
return std::make_unique<SystemProcess>(pid);
|
||||
}
|
||||
}
|
||||
#endif // __APPLE_
|
||||
#endif
|
||||
|
||||
std::stringstream ss;
|
||||
ss << executable;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue