summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2021-09-20 11:59:13 +0200
committerJeremy Allison <jra@samba.org>2021-09-21 00:13:32 +0000
commit6f973a4f79bcde2ee13047cd7dd1ff3a105f3d0e (patch)
treeb11f01ad43a58e4282f4081dc3931a5254013994 /source3/printing
parente11881ea1678575797cab3503c8214d11834dd54 (diff)
downloadsamba-6f973a4f79bcde2ee13047cd7dd1ff3a105f3d0e.tar.gz
samba-bgqd: Convert closeall_*() to closefrom_*()
Align it with closefrom() in preparation for use elsewhere Signed-off-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/samba-bgqd.c21
1 files changed, 9 insertions, 12 deletions
diff --git a/source3/printing/samba-bgqd.c b/source3/printing/samba-bgqd.c
index 5a5fc488f5a..11b364afea7 100644
--- a/source3/printing/samba-bgqd.c
+++ b/source3/printing/samba-bgqd.c
@@ -155,7 +155,7 @@ static int samba_bgqd_pidfile_create(
return EAGAIN;
}
-static int closeall_except(int *fds, size_t num_fds)
+static int closefrom_except(int lower, int *fds, size_t num_fds)
{
size_t i;
int max_keep = -1;
@@ -168,7 +168,7 @@ static int closeall_except(int *fds, size_t num_fds)
return 0;
}
- for (fd = 0; fd < max_keep; fd++) {
+ for (fd = lower; fd < max_keep; fd++) {
bool keep = false;
/*
@@ -191,17 +191,18 @@ static int closeall_except(int *fds, size_t num_fds)
}
}
- closefrom(max_keep+1);
+ closefrom(MAX(lower, max_keep+1));
return 0;
}
-static int closeall_except_fd_params(
+static int closefrom_except_fd_params(
+ int lower,
size_t num_fd_params,
const char *fd_params[],
int argc,
const char *argv[])
{
- int fds[num_fd_params+3];
+ int fds[num_fd_params];
size_t i;
struct poptOption long_options[num_fd_params + 1];
poptContext pc;
@@ -217,10 +218,6 @@ static int closeall_except_fd_params(
}
long_options[num_fd_params] = (struct poptOption) { .longName=NULL, };
- fds[num_fd_params] = 0;
- fds[num_fd_params+1] = 1;
- fds[num_fd_params+2] = 2;
-
pc = poptGetContext(argv[0], argc, argv, long_options, 0);
while ((ret = poptGetNextOpt(pc)) != -1) {
@@ -229,7 +226,7 @@ static int closeall_except_fd_params(
poptFreeContext(pc);
- ret = closeall_except(fds, ARRAY_SIZE(fds));
+ ret = closefrom_except(lower, fds, ARRAY_SIZE(fds));
return ret;
}
@@ -304,8 +301,8 @@ int main(int argc, const char *argv[])
"ready-signal-fd", "parent-watch-fd",
};
- closeall_except_fd_params(
- ARRAY_SIZE(fd_params), fd_params, argc, argv);
+ closefrom_except_fd_params(
+ 3, ARRAY_SIZE(fd_params), fd_params, argc, argv);
}
talloc_enable_null_tracking();