diff --git a/cbits/posix/posix_spawn.c b/cbits/posix/posix_spawn.c
--- a/cbits/posix/posix_spawn.c
+++ b/cbits/posix/posix_spawn.c
@@ -1,3 +1,7 @@
+// Necessary for POSIX_SPAWN_SETSID and posix_spawn_file_actions_addchdir_np under glibc.
+// Moreover this needs to appear before any glibc headers.
+#define _GNU_SOURCE
+
 #include "runProcess.h"
 #include "common.h"
 
@@ -25,8 +29,6 @@
 
 #else
 
-// Necessary for POSIX_SPAWN_SETSID under glibc.
-#define _GNU_SOURCE
 #include <spawn.h>
 
 extern char **environ;
@@ -135,13 +137,13 @@
     }
 
     if (workingDirectory) {
-#if defined(HAVE_posix_spawn_file_actions_addchdir)
+#if defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR)
         r = posix_spawn_file_actions_addchdir(&fa, workingDirectory);
         if (r != 0) {
             *failed_doing = "posix_spawn_file_actions_addchdir";
             goto fail;
         }
-#elif defined(HAVE_posix_spawn_file_actions_addchdir_np)
+#elif defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCHDIR_NP)
         // N.B. this function is broken on macOS.
         // See https://github.com/rust-lang/rust/pull/80537.
         r = posix_spawn_file_actions_addchdir_np(&fa, workingDirectory);
diff --git a/changelog.md b/changelog.md
--- a/changelog.md
+++ b/changelog.md
@@ -1,5 +1,9 @@
 # Changelog for [`process` package](http://hackage.haskell.org/package/process)
 
+## 1.6.24.0 *September 2024*
+
+* Fix detection of `posix_spawn_file_actions_addchdir[_np]` ([#303](https://github.com/haskell/process/issues/303))
+
 ## 1.6.23.0 *September 2024*
 
 * Fix command-line escaping logic on Windows when the command file ends with
diff --git a/process.cabal b/process.cabal
--- a/process.cabal
+++ b/process.cabal
@@ -1,6 +1,6 @@
 cabal-version: 2.4
 name:          process
-version:       1.6.23.0
+version:       1.6.24.0
 -- NOTE: Don't forget to update ./changelog.md
 license:       BSD-3-Clause
 license-file:  LICENSE
