cmogstored 1.8.1 - use default system stack size
[cmogstored.git] / cloexec_from.c
blob178ecdabd556dd2e9888f9c8b3f96b551d76df01
1 /*
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>
4 */
5 #include "cmogstored.h"
7 /*
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 */
14 int fd;
15 int last_good = lowfd;
17 for (fd = lowfd; fd < INT_MAX; fd++) {
18 if (mog_set_cloexec(fd, true) == 0)
19 last_good = fd;
20 if ((last_good + 1024) < fd)
21 break;