On Thu, Mar 14, 2019 at 4:35 PM Arnout Vandecappelle <[email protected]> wrote:
> The problem is that the assumption that open() returns an fd that is larger
> than all existing fds is simply wrong.
>
> I think that there is no other way to close all open fds than to iterate over
> /proc/self/fd. But that is of course not very portable.
This particular issue could be fixed by rewriting the logic to something like:
int keep = 2;
if (flags & DAEMON_DEVNULL_STDIO)
keep = -1;
fd = open(bb_dev_null, O_RDWR);
..
while (fd > keep) {
close(fd--);
}
But yeah, the other problem persists. I don't know of any other
solutions besides using a hardcoded max-fd. I believe the classic
limit used by select is 1024.
--
Bye, Peter Korsgaard
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox