Commit 4d5dd87b authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Don't use getdtablesize() for closing existing fd's it only

represents the current limit.

Also don't call it every iteration of the loop.
parent b6950530
......@@ -530,7 +530,7 @@ main(int argc, char * const *argv)
* Start out by closing all unwanted file descriptors we might
* have inherited from sloppy process control daemons.
*/
for (o = getdtablesize(); o > STDERR_FILENO; o--)
for (o = sysconf(_SC_OPEN_MAX); o > STDERR_FILENO; o--)
(void)close(o);
VRND_Seed();
......
......@@ -203,7 +203,7 @@ process_start(struct process *p)
assert(dup2(p->fds[0], 0) == 0);
assert(dup2(out_fd, 1) == 1);
assert(dup2(err_fd, 2) == 2);
for (i = 3; i <getdtablesize(); i++)
for (i = sysconf(_SC_OPEN_MAX); i > STDERR_FILENO; i--)
(void)close(i);
AZ(execl("/bin/sh", "/bin/sh", "-c", VSB_data(cl), (char*)0));
exit(1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment