diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-11-02 11:54:03 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-11-06 10:16:08 -0500 |
commit | 95fbde17a66377b6fbe7ff1f014301dbbf09270d (patch) | |
tree | 5a98afd0242afc959a0317c52ab842d8e45030ad /src/xspawn.h | |
parent | ad1b36291fe87ca9d647980e3afdc71344d66519 (diff) | |
download | bfs-95fbde17a66377b6fbe7ff1f014301dbbf09270d.tar.xz |
xspawn: Wrap the real posix_spawn() if possible
Fixes #47.
Diffstat (limited to 'src/xspawn.h')
-rw-r--r-- | src/xspawn.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/xspawn.h b/src/xspawn.h index d9b4a2e..2a3d736 100644 --- a/src/xspawn.h +++ b/src/xspawn.h @@ -8,6 +8,8 @@ #ifndef BFS_XSPAWN_H #define BFS_XSPAWN_H +#include "config.h" +#include <spawn.h> #include <sys/resource.h> #include <sys/types.h> @@ -16,16 +18,25 @@ */ enum bfs_spawn_flags { /** Use the PATH variable to resolve the executable (like execvp()). */ - BFS_SPAWN_USEPATH = 1 << 0, + BFS_SPAWN_USE_PATH = 1 << 0, + /** Whether posix_spawn() can be used. */ + BFS_SPAWN_USE_POSIX = 1 << 1, }; /** * bfs_spawn() attributes, controlling the context of the new process. */ struct bfs_spawn { + /** Spawn flags. */ enum bfs_spawn_flags flags; + + /** Linked list of actions. */ struct bfs_spawn_action *head; struct bfs_spawn_action **tail; + + /** pthread_spawn() context, for when we can use it. */ + posix_spawnattr_t attr; + posix_spawn_file_actions_t actions; }; /** @@ -95,7 +106,7 @@ 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() + * Look up an executable in the current PATH, as BFS_SPAWN_USE_PATH or execvp() * would do. * * @param exe |