Skip to content

Commit

Permalink
fix: G_SPAWN default io flags aren't available before 2.74
Browse files Browse the repository at this point in the history
  • Loading branch information
aarondill committed Jul 2, 2024
1 parent cf493d9 commit 2268d4c
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,9 +450,12 @@ luaA_spawn(lua_State *L)
if(lua_gettop(L) >= 3) {
if (lua_isstring(L, 3)) {
const char *str = lua_tostring(L, 3);
if (a_strcmp(str, "DEV_NULL") == 0)
if (a_strcmp(str, "DEV_NULL") == 0){
// This is the default behaviour. Compiles to a no-op before 2.74.
#if GLIB_CHECK_VERSION(2, 74, 0)
flags |= G_SPAWN_STDIN_FROM_DEV_NULL;
else if (a_strcmp(str, "INHERIT") == 0)
# endif
} else if (a_strcmp(str, "INHERIT") == 0)
flags |= G_SPAWN_CHILD_INHERITS_STDIN;
else
luaA_typerror(L, 3, "DEV_NULL or INHERIT");
Expand All @@ -467,9 +470,12 @@ luaA_spawn(lua_State *L)
const char *str = lua_tostring(L, 4);
if (a_strcmp(str, "DEV_NULL") == 0)
flags |= G_SPAWN_STDOUT_TO_DEV_NULL;
else if (a_strcmp(str, "INHERIT") == 0)
else if (a_strcmp(str, "INHERIT") == 0) {
// This is the default behaviour. Compiles to a no-op before 2.74.
#if GLIB_CHECK_VERSION(2, 74, 0)
flags |= G_SPAWN_CHILD_INHERITS_STDOUT;
else
# endif
} else
luaA_typerror(L, 4, "DEV_NULL or INHERIT");
} else if(lua_isboolean(L, 4)) {
return_stdout = lua_toboolean(L, 4);
Expand All @@ -482,9 +488,12 @@ luaA_spawn(lua_State *L)
const char *str = lua_tostring(L, 5);
if (a_strcmp(str, "DEV_NULL") == 0)
flags |= G_SPAWN_STDERR_TO_DEV_NULL;
else if (a_strcmp(str, "INHERIT") == 0)
else if (a_strcmp(str, "INHERIT") == 0) {
// This is the default behaviour. Compiles to a no-op before 2.74.
#if GLIB_CHECK_VERSION(2, 74, 0)
flags |= G_SPAWN_CHILD_INHERITS_STDERR;
else
# endif
} else
luaA_typerror(L, 5, "DEV_NULL or INHERIT");
} else if(lua_isboolean(L, 5)) {
return_stderr = lua_toboolean(L, 5);
Expand Down

0 comments on commit 2268d4c

Please sign in to comment.