summaryrefslogtreecommitdiffstats
path: root/spawn.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2018-09-18 21:29:59 -0400
committerTavian Barnes <tavianator@tavianator.com>2018-09-18 22:04:07 -0400
commitabf4394ae34bf25a17efb9fa560791005a6b217b (patch)
tree8717654c659deead1c8c162407cf2633ccb14ea5 /spawn.h
parent727562e99082e9ed808b5ff6e02b65b9cf5b65c3 (diff)
downloadbfs-abf4394ae34bf25a17efb9fa560791005a6b217b.tar.xz
spawn: New posix_spawn()-like API for exec
Diffstat (limited to 'spawn.h')
-rw-r--r--spawn.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/spawn.h b/spawn.h
new file mode 100644
index 0000000..6a8a15c
--- /dev/null
+++ b/spawn.h
@@ -0,0 +1,43 @@
+/****************************************************************************
+ * bfs *
+ * Copyright (C) 2018 Tavian Barnes <tavianator@tavianator.com> *
+ * *
+ * Permission to use, copy, modify, and/or distribute this software for any *
+ * purpose with or without fee is hereby granted. *
+ * *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES *
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF *
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR *
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES *
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN *
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *
+ ****************************************************************************/
+
+#ifndef BFS_SPAWN_H
+#define BFS_SPAWN_H
+
+#include <stdbool.h>
+#include <signal.h>
+#include <sys/types.h>
+
+enum bfs_spawn_flags {
+ BFS_SPAWN_USEPATH = 1 << 0,
+};
+
+struct bfs_spawn {
+ enum bfs_spawn_flags flags;
+ struct bfs_spawn_action *actions;
+ struct bfs_spawn_action **tail;
+};
+
+int bfs_spawn_init(struct bfs_spawn *ctx);
+int bfs_spawn_destroy(struct bfs_spawn *ctx);
+
+int bfs_spawn_setflags(struct bfs_spawn *ctx, enum bfs_spawn_flags flags);
+
+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);
+
+#endif // BFS_SPAWN_H