From a8b0ea58e60bb0326b7f7c8f3c736d89ce9ef1df Mon Sep 17 00:00:00 2001 From: Lexi Winter Date: Sun, 29 Jun 2025 19:19:23 +0100 Subject: wip macOS port --- nihil.posix/fexecv.ccm | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 nihil.posix/fexecv.ccm (limited to 'nihil.posix/fexecv.ccm') 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 +#include + +#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; + + // 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 -- cgit v1.2.3