From c7c678651a30db30e449e965e6c82ad0dcb871e6 Mon Sep 17 00:00:00 2001 From: Jonathan Bradley Date: Mon, 18 Dec 2023 20:35:37 -0500 Subject: checkpoint - arg-handler --- editor/editor.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'editor/editor.cpp') diff --git a/editor/editor.cpp b/editor/editor.cpp index 53d8883..4170ac9 100644 --- a/editor/editor.cpp +++ b/editor/editor.cpp @@ -105,16 +105,24 @@ void PkeEditor_Tick(double delta) { PkeThreads_Enqueue(threadPoolHandle, std::packaged_task( [] { auto pid = fork(); if (pid == 0) { + char pluginOpt[128]; + pluginOpt[127] = '\n'; + sprintf(pluginOpt, "--plugin %s", pkeSettings.pluginPath == nullptr ? "example.o" : pkeSettings.pluginPath); + int status = -1; const char *argv[] = { + pluginOpt, NULL, }; - int status = execvp("pke_runtime", const_cast(argv)); - fprintf(stderr, "pke_runtime exited with a status of %i\n", status); + status = execvp("pke_runtime", const_cast(argv)); + fprintf(stderr, "pke_runtime (child) exited with a status of %i\n", status); + subProgramRunning = false; + } else if (pid == -1) { + fprintf(stdout, "pke_runtime failed to fork\n"); subProgramRunning = false; } else { - int status; + int status = 0xCAFEBABE; waitpid(pid, &status, 0); - fprintf(stdout, "pke_runtime exited cleanly with a status of %i\n", status); + fprintf(stdout, "pke_runtime (parent) exited with a status of %i (0x%08X)\n", status, status); subProgramRunning = false; } })); -- cgit v1.2.3