summaryrefslogtreecommitdiffstats
path: root/src/xspawn.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-11-06 10:12:21 -0500
committerTavian Barnes <tavianator@tavianator.com>2022-11-06 16:37:14 -0500
commit2724dfbd17552f892a0d8b39b96cbe9e49d66fdb (patch)
tree5a1534a0f0097427e00f45859b110acefddf35f3 /src/xspawn.c
parentb7a222b6f9e0b7acea4a108928267b5ed658fdb5 (diff)
downloadbfs-2724dfbd17552f892a0d8b39b96cbe9e49d66fdb.tar.xz
xspawn: Use _PATH_DEFPATH if _CS_PATH is not defined
And set errno correctly if neither one is. Fixes tests/posix/exec_nopath on Android.
Diffstat (limited to 'src/xspawn.c')
-rw-r--r--src/xspawn.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/xspawn.c b/src/xspawn.c
index 67e0572..43a6f1c 100644
--- a/src/xspawn.c
+++ b/src/xspawn.c
@@ -24,6 +24,10 @@
#include <sys/wait.h>
#include <unistd.h>
+#if BFS_HAS_PATHS
+# include <paths.h>
+#endif
+
/**
* Types of spawn actions.
*/
@@ -260,11 +264,15 @@ char *bfs_spawn_resolve(const char *exe) {
const char *path = getenv("PATH");
char *confpath = NULL;
-#ifdef _CS_PATH
if (!path) {
+#if defined(_CS_PATH)
path = confpath = xconfstr(_CS_PATH);
- }
+#elif defined(_PATH_DEFPATH)
+ path = _PATH_DEFPATH;
+#else
+ errno = ENOENT;
#endif
+ }
if (!path) {
return NULL;
}