ucm: exec - fix maxfd used warning

Fixes: a068cf08 ("ucm: use closefrom instead of close_range")
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
Jaroslav Kysela 2025-12-09 17:48:34 +01:00
parent a068cf08ad
commit 813ffe34ff

View file

@ -183,7 +183,7 @@ static int parse_args(char ***argv, int argc, const char *cmd)
*/ */
int uc_mgr_exec(const char *prog) int uc_mgr_exec(const char *prog)
{ {
pid_t p, f, maxfd; pid_t p, f;
int err = 0, status; int err = 0, status;
char bin[PATH_MAX]; char bin[PATH_MAX];
struct sigaction sa; struct sigaction sa;
@ -212,8 +212,6 @@ int uc_mgr_exec(const char *prog)
prog = bin; prog = bin;
} }
maxfd = sysconf(_SC_OPEN_MAX);
/* /*
* block SIGCHLD signal * block SIGCHLD signal
* ignore SIGINT and SIGQUIT in parent * ignore SIGINT and SIGQUIT in parent
@ -262,8 +260,11 @@ int uc_mgr_exec(const char *prog)
#if HAVE_DECL_CLOSEFROM #if HAVE_DECL_CLOSEFROM
closefrom(3); closefrom(3);
#else #else
for (f = 3; f < maxfd; f++) {
close(f); pid_t maxfd = sysconf(_SC_OPEN_MAX);
for (f = 3; f < maxfd; f++)
close(f);
}
#endif #endif
/* install default handlers for the forked process */ /* install default handlers for the forked process */