From b5c9656a2f5be060491fae98f589f66855b8a638 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 19 Sep 2018 18:41:33 -0400 Subject: spawn: Add some docs --- spawn.h | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) (limited to 'spawn.h') diff --git a/spawn.h b/spawn.h index 6a8a15c..ef510e1 100644 --- a/spawn.h +++ b/spawn.h @@ -21,23 +21,65 @@ #include #include +/** + * bfs_spawn() flags. + */ enum bfs_spawn_flags { + /** Use the PATH variable to resolve the executable (like execvp()). */ BFS_SPAWN_USEPATH = 1 << 0, }; +/** + * bfs_spawn() attributes, controlling the context of the new process. + */ struct bfs_spawn { enum bfs_spawn_flags flags; struct bfs_spawn_action *actions; struct bfs_spawn_action **tail; }; +/** + * Create a new bfs_spawn() context. + * + * @return 0 on success, -1 on failure. + */ int bfs_spawn_init(struct bfs_spawn *ctx); + +/** + * Destroy a bfs_spawn() context. + * + * @return 0 on success, -1 on failure. + */ int bfs_spawn_destroy(struct bfs_spawn *ctx); +/** + * Set the flags for a bfs_spawn() context. + * + * @return 0 on success, -1 on failure. + */ int bfs_spawn_setflags(struct bfs_spawn *ctx, enum bfs_spawn_flags flags); +/** + * Add an fchdir() action to a bfs_spawn() context. + * + * @return 0 on success, -1 on failure. + */ int bfs_spawn_addfchdir(struct bfs_spawn *ctx, int fd); -pid_t bfs_spawn(const char *file, const struct bfs_spawn *ctx, char **argv, char **envp); +/** + * Spawn a new process. + * + * @param exe + * The executable to run. + * @param ctx + * The context for the new process. + * @param argv + * The arguments for the new process. + * @param envp + * The environment variables for the new process. + * @return + * The PID of the new process, or -1 on error. + */ +pid_t bfs_spawn(const char *exe, const struct bfs_spawn *ctx, char **argv, char **envp); #endif // BFS_SPAWN_H -- cgit v1.2.3