From 88704c6ecbdf5b5b4c1e3e727457ecfc5594c8c8 Mon Sep 17 00:00:00 2001 From: jgmdev Date: Tue, 22 Jun 2021 15:01:30 -0400 Subject: [PATCH 1/2] [api/process] added missing fields and minor fix to pid() --- src/api/process.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/api/process.c b/src/api/process.c index 57c74d5c..111667a1 100644 --- a/src/api/process.c +++ b/src/api/process.c @@ -132,7 +132,13 @@ static int process_pid(lua_State* L) process_t* self = (process_t*) lua_touserdata(L, 1); if(self->process){ - lua_pushnumber(L, reproc_pid(self->process)); + int id = reproc_pid(self->process); + + if(id > 0){ + lua_pushnumber(L, id); + } else { + lua_pushnumber(L, 0); + } } else { lua_pushnumber(L, 0); } @@ -393,9 +399,12 @@ static const struct luaL_Reg process[] = { {"ERROR_PIPE", NULL}, {"ERROR_WOULDBLOCK", NULL}, {"ERROR_TIMEDOUT", NULL}, + {"ERROR_INVALID", NULL}, {"STREAM_STDIN", NULL}, {"STREAM_STDOUT", NULL}, {"STREAM_STDERR", NULL}, + {"WAIT_INFINITE", NULL}, + {"WAIT_DEADLINE", NULL}, {NULL, NULL} }; @@ -417,6 +426,9 @@ int luaopen_process(lua_State *L) lua_pushnumber(L, REPROC_ETIMEDOUT); lua_setfield(L, -2, "ERROR_TIMEDOUT"); + lua_pushnumber(L, REPROC_EINVAL); + lua_setfield(L, -2, "ERROR_INVALID"); + lua_pushnumber(L, REPROC_STREAM_IN); lua_setfield(L, -2, "STREAM_STDIN"); @@ -426,5 +438,11 @@ int luaopen_process(lua_State *L) lua_pushnumber(L, REPROC_STREAM_ERR); lua_setfield(L, -2, "STREAM_STDERR"); + lua_pushnumber(L, REPROC_INFINITE); + lua_setfield(L, -2, "WAIT_INFINITE"); + + lua_pushnumber(L, REPROC_DEADLINE); + lua_setfield(L, -2, "WAIT_DEADLINE"); + return 1; } From 79581b551b24e2ed9b4667065aade42ab3271196 Mon Sep 17 00:00:00 2001 From: takase1121 <20792268+takase1121@users.noreply.github.com> Date: Sun, 27 Jun 2021 23:14:48 +0800 Subject: [PATCH 2/2] change double quotes to single quotes to reduce escaping --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 46befe51..3aacf828 100644 --- a/src/main.c +++ b/src/main.c @@ -172,8 +172,8 @@ init_lua: "local core\n" "xpcall(function()\n" " HOME = os.getenv('" LITE_OS_HOME "')\n" - " local exedir = EXEFILE:match(\"^(.*)" LITE_PATHSEP_PATTERN LITE_NONPATHSEP_PATTERN "$\")\n" - " local prefix = exedir:match(\"^(.*)" LITE_PATHSEP_PATTERN "bin$\")\n" + " local exedir = EXEFILE:match('^(.*)" LITE_PATHSEP_PATTERN LITE_NONPATHSEP_PATTERN "$')\n" + " local prefix = exedir:match('^(.*)" LITE_PATHSEP_PATTERN "bin$')\n" " dofile((MACOS_RESOURCES or (prefix and prefix .. '/share/lite-xl' or exedir .. '/data')) .. '/core/start.lua')\n" " core = require('core')\n" " core.init()\n"