From 2cf5fd3d5dd20035d694f4f5116cf5bd48765cd1 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 21 Feb 2021 22:39:32 -0600 Subject: [PATCH] Avoid hard compilation errors on platforms w/out O_ASYNC Those platforms should not be using the sigio notifier in the first place, this just stops them from failing to be able to compile fish altogether. See #6585 --- src/env_universal_common.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/env_universal_common.cpp b/src/env_universal_common.cpp index 87cbc6951..36f69cc72 100644 --- a/src/env_universal_common.cpp +++ b/src/env_universal_common.cpp @@ -1374,9 +1374,13 @@ class universal_notifier_sigio_t final : public universal_notifier_t { } // Note that O_ASYNC cannot be passed to open() (see Linux kernel bug #5993). // We have to set it afterwards like so. - // Also Linux got support for O_ASYNC on fifos in 2.6 (released 2003). - // Do not be noisy if this fails. - if (fcntl(pipe.fd(), F_SETFL, O_NONBLOCK | O_ASYNC) == -1) { + // Linux got support for O_ASYNC on fifos in 2.6 (released 2003). Treat its absence as a + // failure, but don't be noisy if this fails. Non-Linux platforms without O_ASYNC should use + // a different notifier strategy to avoid running into this. +#ifdef O_ASYNC + if (fcntl(pipe.fd(), F_SETFL, O_NONBLOCK | O_ASYNC) == -1) +#endif + { FLOGF(uvar_file, _(L"fcntl(F_SETFL) failed, universal variable notifications disabled")); return autoclose_fd_t{};