Skip to content

Commit

Permalink
added musl workaround.
Browse files Browse the repository at this point in the history
  • Loading branch information
klemens-morgenstern committed Jul 2, 2024
1 parent 3400d76 commit 22e6e65
Showing 1 changed file with 28 additions and 3 deletions.
31 changes: 28 additions & 3 deletions src/posix/close_handles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <boost/process/v2/posix/detail/close_handles.hpp>

#include <algorithm>
#include <memory>

// linux has close_range since 5.19

Expand Down Expand Up @@ -44,23 +45,47 @@ int fdwalk(int (*func)(void *, int), void *cd);

#include <linux/version.h>

#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0) // kernel has close_range

#include <gnu/libc-version.h>
#if (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 34) // glibc is compiled with close_range support
// https://man7.org/linux/man-pages/man2/close_range.2.html

#include <linux/close_range.h>
#define BOOST_PROCESS_V2_HAS_CLOSE_RANGE 1
#define BOOST_PROCESS_V2_HAS_CLOSE_RANGE 1
#else

#include <sys/syscall.h>

#if defined(SYS_close_range)

#define BOOST_PROCESS_V2_HAS_CLOSE_RANGE 1
int close_range(unsigned int first, unsigned int last, int flags)
{
return ::syscall(SYS_close_range, first, last, flags);
}

#else

#include <dirent.h>

#endif

#endif


#else

#include <dirent.h>

#endif

#else

#include <dirent.h>

#endif


BOOST_PROCESS_V2_BEGIN_NAMESPACE

namespace posix
Expand Down

0 comments on commit 22e6e65

Please sign in to comment.