summaryrefslogtreecommitdiffstats
path: root/src/xspawn.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-08-09 23:26:25 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-08-09 23:28:55 -0400
commit1507cc211f6ce5b4f20f83470eacf44755a0cdcc (patch)
tree79f204eeb7ebdceeee027297d48d1d59802d3f66 /src/xspawn.h
parentbaf9ee660c9f1d44d64341e225f9e0d7b808424d (diff)
downloadbfs-1507cc211f6ce5b4f20f83470eacf44755a0cdcc.tar.xz
bfstd: New sysoption() macro to check for POSIX option runtime support
POSIX allows optional features to be supported at compile time but not necessarily at run time by defining _POSIX_OPTION to 0 and requiring users to check sysconf(_SC_OPTION) > 0. The new sysoption() macro simplifies the check. sighook() and bfs_spawn() now check for conditional runtime support for the relevant POSIX options.
Diffstat (limited to 'src/xspawn.h')
-rw-r--r--src/xspawn.h10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/xspawn.h b/src/xspawn.h
index 6a8f54a..05dcf99 100644
--- a/src/xspawn.h
+++ b/src/xspawn.h
@@ -13,7 +13,13 @@
#include <sys/types.h>
#include <unistd.h>
-#if _POSIX_SPAWN > 0
+#ifdef _POSIX_SPAWN
+# define BFS_POSIX_SPAWN _POSIX_SPAWN
+#else
+# define BFS_POSIX_SPAWN (-1)
+#endif
+
+#if BFS_POSIX_SPAWN >= 0
# include <spawn.h>
#endif
@@ -38,7 +44,7 @@ struct bfs_spawn {
struct bfs_spawn_action *head;
struct bfs_spawn_action **tail;
-#if _POSIX_SPAWN > 0
+#if BFS_POSIX_SPAWN >= 0
/** posix_spawn() context, for when we can use it. */
posix_spawn_file_actions_t actions;
posix_spawnattr_t attr;