aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/fexecv.ccm
diff options
context:
space:
mode:
authorLexi Winter <lexi@le-fay.org>2025-06-29 19:19:23 +0100
committerLexi Winter <lexi@le-fay.org>2025-06-29 19:19:23 +0100
commita8b0ea58e60bb0326b7f7c8f3c736d89ce9ef1df (patch)
tree6dafcf2674780649dcdc2649855722357837a68e /nihil.posix/fexecv.ccm
parent4fa6821e0645ff61a9380cd090abff472205c630 (diff)
downloadnihil-a8b0ea58e60bb0326b7f7c8f3c736d89ce9ef1df.tar.gz
nihil-a8b0ea58e60bb0326b7f7c8f3c736d89ce9ef1df.tar.bz2
wip macOS port
Diffstat (limited to 'nihil.posix/fexecv.ccm')
-rw-r--r--nihil.posix/fexecv.ccm53
1 files changed, 53 insertions, 0 deletions
diff --git a/nihil.posix/fexecv.ccm b/nihil.posix/fexecv.ccm
new file mode 100644
index 0000000..5ad6c62
--- /dev/null
+++ b/nihil.posix/fexecv.ccm
@@ -0,0 +1,53 @@
+/*
+ * This source code is released into the public domain.
+ */
+
+module;
+
+#include <expected>
+#include <string>
+
+#include "nihil.hh"
+
+#ifdef NIHIL_HAVE_FEXECVE
+
+export module nihil.posix:fexecv;
+
+import nihil.error;
+import :argv;
+import :executor;
+import :fd;
+
+namespace nihil {
+
+/*
+ * fexecv: use a file descriptor and an argument vector to call ::fexecve().
+ * This is the lowest-level executor which all others are implemented
+ * in terms of (if it's available).
+ *
+ * TODO: Should have a way to pass the environment (envp).
+ */
+export struct fexecv final {
+ using tag = exec_tag;
+
+ fexecv(fd &&execfd, argv &&args) noexcept;
+
+ [[nodiscard]] auto exec(this fexecv &self)
+ -> std::expected<void, error>;
+
+ // Movable
+ fexecv(fexecv &&) noexcept;
+ auto operator=(this fexecv &, fexecv &&) noexcept -> fexecv&;
+
+ // Not copyable (because we hold the open fd object)
+ fexecv(fexecv const &) = delete;
+ auto operator=(this fexecv &, fexecv const &) -> fexecv& = delete;
+
+private:
+ fd m_execfd;
+ argv m_args;
+};
+
+} // namespace nihil
+
+#endif // NIHIL_HAVE_FEXECVE \ No newline at end of file