diff --git a/cmake/ConfigureChecks.cmake b/cmake/ConfigureChecks.cmake index 6562d324f..8bd74d809 100644 --- a/cmake/ConfigureChecks.cmake +++ b/cmake/ConfigureChecks.cmake @@ -268,6 +268,16 @@ IF (NOT LIBATOMIC_NOT_NEEDED) set(ATOMIC_LIBRARY "atomic") endif() +check_cxx_source_compiles(" +#include + +int main() { + static_assert(WEXITSTATUS(0x007f) == 0x7f); + return 0; +} +" +HAVE_WAITSTATUS_SIGNAL_RET) + IF (APPLE) # Check if mbrtowc implementation attempts to encode invalid UTF-8 sequences # Known culprits: at least some versions of macOS (confirmed Snow Leopard and Yosemite) diff --git a/config_cmake.h.in b/config_cmake.h.in index a8b4840fd..c690172ca 100644 --- a/config_cmake.h.in +++ b/config_cmake.h.in @@ -103,6 +103,9 @@ /* Define to 1 if you have the `wcstod_l' function. */ #cmakedefine HAVE_WCSTOD_L 1 +/* Define to 1 if the status that wait returns and WEXITSTATUS expects is signal and then ret instead of the other way around. */ +#cmakedefine HAVE_WAITSTATUS_SIGNAL_RET 1 + /* Define to 1 if the winsize struct and TIOCGWINSZ macro exist */ #cmakedefine HAVE_WINSIZE 1 diff --git a/src/proc.h b/src/proc.h index 1b6ed6e60..7aa018ea2 100644 --- a/src/proc.h +++ b/src/proc.h @@ -73,7 +73,7 @@ class proc_status_t { static constexpr int w_exitcode(int ret, int sig) { #ifdef W_EXITCODE return W_EXITCODE(ret, sig); -#elif WEXITSTATUS(0x007f) == 0x7f +#elif HAVE_WAITSTATUS_SIGNAL_RET // It's encoded signal and then status // The return status is in the lower byte. return ((sig) << 8 | (ret));