From 0ac7b2d5e7b0e43974f8b9846082daf006e62275 Mon Sep 17 00:00:00 2001 From: 3405691582 Date: Tue, 27 Oct 2026 17:25:39 +0000 Subject: [PATCH] Make graphics_detector build on multiple platforms Here, a Linux syscall is made and a fallback used if the kernel version doesn't support the syscall. But this doesn't consider that we may not be running on Linux, so forcibly return an error in this case. While we are here, tidy includes. --- .../cuttlefish/host/graphics_detector/BUILD.bazel | 1 + .../host/graphics_detector/subprocess.cpp | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/base/cvd/cuttlefish/host/graphics_detector/BUILD.bazel b/base/cvd/cuttlefish/host/graphics_detector/BUILD.bazel index 538ad118797..344ce664b57 100644 --- a/base/cvd/cuttlefish/host/graphics_detector/BUILD.bazel +++ b/base/cvd/cuttlefish/host/graphics_detector/BUILD.bazel @@ -63,6 +63,7 @@ cf_cc_binary( deps = [ ":graphics_detector_cc_proto", "//cuttlefish/host/graphics_detector/shaders:graphics_detector_shaders", + "//cuttlefish/posix:temp_failure_retry", "@abseil-cpp//absl/log", "@egl_headers", "@opengl_headers//:GLES2_headers", diff --git a/base/cvd/cuttlefish/host/graphics_detector/subprocess.cpp b/base/cvd/cuttlefish/host/graphics_detector/subprocess.cpp index 01b6e697954..80755f61e1a 100644 --- a/base/cvd/cuttlefish/host/graphics_detector/subprocess.cpp +++ b/base/cvd/cuttlefish/host/graphics_detector/subprocess.cpp @@ -17,17 +17,23 @@ #include "cuttlefish/host/graphics_detector/subprocess.h" #include +#include #include +#include #include -#include #include #include +#if defined(__linux__) +#include +#endif #include #include #include #include +#include "cuttlefish/posix/temp_failure_retry.h" // IWYU pragma: keep + namespace gfxstream { namespace { @@ -50,11 +56,17 @@ class ScopedCloser { }; int PidfdOpen(pid_t pid) { +#if defined(__linux__) // There is no glibc wrapper for pidfd_open. #ifndef SYS_pidfd_open constexpr int SYS_pidfd_open = 434; #endif return syscall(SYS_pidfd_open, pid, /*flags=*/0); +#else + (void)pid; + errno = ENOSYS; + return -1; +#endif } gfxstream::expected WaitForChild(pid_t pid) {