Skip to content

Commit

Permalink
Fix false positives from Lua scriptlet runaway child detection
Browse files Browse the repository at this point in the history
Commit a810765 moved the detection
to parent using waitpid(), but this causes it to complain on any
process in the same process group. In the usual rpm context we don't
have any, but we can't very well tell API users not to have any
children.

rpmlog() in the child has the issues mentioned in the originating
commit, but that's a problem that needs to be solved elsewhere.
Revert back to issuing a warning when we actually *are* in the child
process, so there are no false positive possible.

Reported at https://bugzilla.redhat.com/show_bug.cgi?id=2254463
  • Loading branch information
pmatilai committed Dec 15, 2023
1 parent 4ecefc7 commit 0583d00
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions rpmio/rpmlua.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,17 +239,13 @@ static int luaopt(int c, const char *oarg, int oint, void *data)
static int rpm_pcall(lua_State *L, int nargs, int nresults, int errfunc)
{
pid_t pid = getpid();
int status;

int rc = lua_pcall(L, nargs, nresults, errfunc);

/* Terminate unhandled fork from Lua script */
if (pid != getpid())
if (pid != getpid()) {
rpmlog(RPMLOG_WARNING, _("runaway fork() in Lua script %u\n"), getpid());
_exit(1);

if (waitpid(0, &status, WNOHANG) == 0) {
rpmlog(RPMLOG_WARNING,
_("runaway fork() in Lua script\n"));
}

return rc;
Expand Down

0 comments on commit 0583d00

Please sign in to comment.