From 7f212025dea41df2369ed922b46bf27932f653bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Wed, 5 Feb 2025 15:36:09 +0800 Subject: [PATCH] Processing (Unix): better `pipe2(2)` existance check --- CMakeLists.txt | 7 +++++++ src/common/processing_linux.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95d74a2b0..103b20b19 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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}) diff --git a/src/common/processing_linux.c b/src/common/processing_linux.c index 63d395114..1839a4368 100644 --- a/src/common/processing_linux.c +++ b/src/common/processing_linux.c @@ -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);