aboutsummaryrefslogtreecommitdiff
path: root/libexec/flua
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2025-07-09 05:12:31 +0000
committerKyle Evans <kevans@FreeBSD.org>2025-07-09 05:12:31 +0000
commit0610ba6cdbf2d8bed2619ae78ef2da5ee9c30b94 (patch)
tree7e67864a4de8b9b0baeb568378d9717477faf58d /libexec/flua
parentd9cc5dd87b50348b60ca8aea1d3445c25e9c1a1c (diff)
Diffstat (limited to 'libexec/flua')
-rw-r--r--libexec/flua/modules/lfbsd.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/libexec/flua/modules/lfbsd.c b/libexec/flua/modules/lfbsd.c
index 30cafcc7309e..6279474f8388 100644
--- a/libexec/flua/modules/lfbsd.c
+++ b/libexec/flua/modules/lfbsd.c
@@ -88,13 +88,22 @@ lua_exec(lua_State *L)
argv = luaL_checkarraystrings(L, 1);
if (0 != (r = posix_spawnp(&pid, argv[0], &action, NULL,
(char*const*)argv, environ))) {
+ close(stdin_pipe[0]);
+ close(stdin_pipe[1]);
+ posix_spawn_file_actions_destroy(&action);
+
lua_pushnil(L);
lua_pushstring(L, strerror(r));
lua_pushinteger(L, r);
return (3);
}
+
+ close(stdin_pipe[0]);
+ posix_spawn_file_actions_destroy(&action);
+
while (waitpid(pid, &pstat, 0) == -1) {
if (errno != EINTR) {
+ close(stdin_pipe[1]);
lua_pushnil(L);
lua_pushstring(L, strerror(r));
lua_pushinteger(L, r);
@@ -109,12 +118,7 @@ lua_exec(lua_State *L)
return (3);
}
- posix_spawn_file_actions_destroy(&action);
-
- if (stdin_pipe[0] != -1)
- close(stdin_pipe[0]);
- if (stdin_pipe[1] != -1)
- close(stdin_pipe[1]);
+ close(stdin_pipe[1]);
lua_pushinteger(L, pid);
return 1;
}