1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| | /*
* Copyright (C) 2012-2016 all contributors <cmogstored-public@bogomips.org>
* License: GPLv3 or later (see COPYING for details)
*/
#include "cmogstored.h"
/*
* this function is only called in a vforked child (for iostat)
* if O_CLOEXEC/SOCK_CLOEXEC is unsupported, or if mog_cloexec_detect()
* detects those flags are broken.
*/
void mog_cloexec_from(int lowfd) /* vfork-safe */
{
int fd;
int last_good = lowfd;
for (fd = lowfd; fd < INT_MAX; fd++) {
if (mog_set_cloexec(fd, true) == 0)
last_good = fd;
if ((last_good + 1024) < fd)
break;
}
}
|