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/execv.ccm | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 nihil.posix/execv.ccm (limited to 'nihil.posix/execv.ccm') diff --git a/nihil.posix/execv.ccm b/nihil.posix/execv.ccm new file mode 100644 index 0000000..ca036a1 --- /dev/null +++ b/nihil.posix/execv.ccm @@ -0,0 +1,47 @@ +/* + * This source code is released into the public domain. + */ + +module; + +#include +#include +#include + +export module nihil.posix:execv; + +import nihil.error; +import :argv; +import :executor; + +namespace nihil { + +/* + * execv: use a filename and an argument vector to call ::execve(). + * This is the lowest-level executor which all others are implemented + * in terms of, if fexecve is not available. + * + * TODO: Should have a way to pass the environment (envp). + */ +export struct execv final +{ + using tag = exec_tag; + + execv(std::filesystem::path, argv &&) noexcept; + + [[nodiscard]] auto exec(this execv &) -> std::expected; + + // Movable + execv(execv &&) noexcept; + auto operator=(this execv &, execv &&) noexcept -> execv &; + + // Copyable. + execv(execv const &); + auto operator=(this execv &, execv const &) -> execv &; + +private: + std::filesystem::path m_path; + argv m_args; +}; + +} // namespace nihil -- cgit v1.2.3