From db67752672877ea0f5360699cb34ad31065ef39e Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 13 Jun 2021 15:53:06 -0400 Subject: spawn: New function for resolving executables in the PATH This fixes the BFS_SPAWN_USEPATH to use the parent's environment, not the new child's environment, to resolve the executable. --- spawn.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'spawn.h') diff --git a/spawn.h b/spawn.h index 16815bb..7bae89c 100644 --- a/spawn.h +++ b/spawn.h @@ -107,4 +107,17 @@ int bfs_spawn_addsetrlimit(struct bfs_spawn *ctx, int resource, const struct rli */ pid_t bfs_spawn(const char *exe, const struct bfs_spawn *ctx, char **argv, char **envp); +/** + * Look up an executable in the current PATH, as BFS_SPAWN_USEPATH or execvp() + * would do. + * + * @param exe + * The name of the binary to execute. Bare names without a '/' will be + * searched on the provided PATH. + * @return + * The full path to the executable, which should be free()'d, or NULL on + * failure. + */ +char *bfs_spawn_resolve(const char *exe); + #endif // BFS_SPAWN_H -- cgit v1.2.3