2 * Copyright (C) 2012-2020 all contributors <cmogstored-public@yhbt.net>
3 * License: GPL-3.0+ <https://www.gnu.org/licenses/gpl-3.0.txt>
5 #include "cmogstored.h"
8 * this function is only called in a vforked child (for iostat)
9 * if O_CLOEXEC/SOCK_CLOEXEC is unsupported, or if mog_cloexec_detect()
10 * detects those flags are broken.
12 void mog_cloexec_from(int lowfd
) /* vfork-safe */
15 int last_good
= lowfd
;
17 for (fd
= lowfd
; fd
< INT_MAX
; fd
++) {
18 if (mog_set_cloexec(fd
, true) == 0)
20 if ((last_good
+ 1024) < fd
)