[flang-commits] [flang] [flang] include sys/wait.h for EXECUTE_COMMAND_LINE (PR #77675)

Dan McGregor via flang-commits flang-commits at lists.llvm.org
Wed Jan 10 11:48:47 PST 2024


https://github.com/dankm created https://github.com/llvm/llvm-project/pull/77675

Linux defines WEXITSTATUS in stdlib.h, but at least FreeBSD and NetBSD only define it in sys/wait.h. Include this header unconditionally, since it is required on the BSDs and should be harmless on other platforms.

Fixes FreeBSD build after #74077.

>From 588e279c3a1c4dcbea9c2d262848eb1d7d49d0d2 Mon Sep 17 00:00:00 2001
From: Dan McGregor <dan.mcgregor at usask.ca>
Date: Wed, 10 Jan 2024 13:33:37 -0600
Subject: [PATCH] [flang] include sys/wait.h for EXECUTE_COMMAND_LINE

Linux defines WEXITSTATUS in stdlib.h, but at least FreeBSD and NetBSD
only define it in sys/wait.h. Include this header unconditionally, since
it is required on the BSDs and should be harmless on other platforms.
---
 flang/runtime/execute.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/flang/runtime/execute.cpp b/flang/runtime/execute.cpp
index 48773ae8114b0b..246495dd4954ad 100644
--- a/flang/runtime/execute.cpp
+++ b/flang/runtime/execute.cpp
@@ -21,6 +21,7 @@
 #include <windows.h>
 #else
 #include <signal.h>
+#include <sys/wait.h>
 #include <unistd.h>
 #endif
 



More information about the flang-commits mailing list