1
0
mirror of https://github.com/falk-werner/webfuse synced 2024-10-27 20:34:10 +00:00

add shim for closefrom to support systems without that function (glibc before 2.34)

This commit is contained in:
Falk Werner 2024-01-08 17:52:05 +01:00 committed by Falk Werner
parent 7fa9dbefe3
commit 9644d46dac
2 changed files with 33 additions and 0 deletions

View File

@ -4,6 +4,22 @@
#include <sys/wait.h>
#include <fcntl.h>
#ifndef closefrom
namespace
{
void closefrom(int fd)
{
int const max_fd = sysconf(_SC_OPEN_MAX);
for(int i = fd; i < max_fd; i++)
{
close(i);
}
}
}
#endif
namespace webfuse
{

View File

@ -9,6 +9,23 @@
#include <stdexcept>
#ifndef closefrom
namespace
{
void closefrom(int fd)
{
int const max_fd = sysconf(_SC_OPEN_MAX);
for(int i = fd; i < max_fd; i++)
{
close(i);
}
}
}
#endif
namespace webfuse
{