mirror of
https://github.com/ceph/ceph
synced 2025-04-01 14:51:13 +00:00
common/fork_function: close all fds in children
Not strictly necessary, but a tidier. Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
parent
f46d76edde
commit
55f76d5ad8
@ -46,6 +46,21 @@ static inline int fork_function(
|
||||
}
|
||||
|
||||
// we are forker (first child)
|
||||
|
||||
// close all fds
|
||||
int maxfd = sysconf(_SC_OPEN_MAX);
|
||||
if (maxfd == -1)
|
||||
maxfd = 16384;
|
||||
for (int fd = 0; fd <= maxfd; fd++) {
|
||||
if (fd == STDIN_FILENO)
|
||||
continue;
|
||||
if (fd == STDOUT_FILENO)
|
||||
continue;
|
||||
if (fd == STDERR_FILENO)
|
||||
continue;
|
||||
::close(fd);
|
||||
}
|
||||
|
||||
sigset_t mask, oldmask;
|
||||
int pid;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user