Processing (Unix): better pipe2(2) existance check

This commit is contained in:
李通洲 2025-02-05 15:36:09 +08:00
parent 63cc8e5523
commit 7f212025de
No known key found for this signature in database
GPG Key ID: 269AD4F5325A22A3
2 changed files with 9 additions and 2 deletions

View File

@ -1182,6 +1182,9 @@ endif()
if(LINUX)
check_function_exists(statx HAVE_STATX)
endif()
if(NOT WIN32)
check_function_exists(pipe2 HAVE_PIPE2)
endif()
if(ENABLE_SYSTEM_YYJSON)
find_package(yyjson)
@ -1296,6 +1299,10 @@ if(HAVE_WCWIDTH)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_WCWIDTH)
endif()
if(HAVE_PIPE2)
target_compile_definitions(libfastfetch PUBLIC FF_HAVE_PIPE2)
endif()
if(NOT "${CUSTOM_PCI_IDS_PATH}" STREQUAL "")
message(STATUS "Custom file path of pci.ids: ${CUSTOM_PCI_IDS_PATH}")
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_PCI_IDS_PATH=${CUSTOM_PCI_IDS_PATH})

View File

@ -32,9 +32,9 @@
enum { FF_PIPE_BUFSIZ = 8192 };
static inline int ffPipe2(int *fds, int flags)
static inline int ffPipe2(int* fds, int flags)
{
#ifdef __APPLE__
#ifndef FF_HAVE_PIPE2
if(pipe(fds) == -1)
return -1;
fcntl(fds[0], F_SETFL, fcntl(fds[0], F_GETFL) | flags);