diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-06-29 19:19:23 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-06-29 19:19:23 +0100 |
| commit | a8b0ea58e60bb0326b7f7c8f3c736d89ce9ef1df (patch) | |
| tree | 6dafcf2674780649dcdc2649855722357837a68e /nihil.posix/execv.ccm | |
| parent | 4fa6821e0645ff61a9380cd090abff472205c630 (diff) | |
| download | nihil-a8b0ea58e60bb0326b7f7c8f3c736d89ce9ef1df.tar.gz nihil-a8b0ea58e60bb0326b7f7c8f3c736d89ce9ef1df.tar.bz2 | |
wip macOS port
Diffstat (limited to 'nihil.posix/execv.ccm')
| -rw-r--r-- | nihil.posix/execv.ccm | 47 |
1 files changed, 47 insertions, 0 deletions
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 <expected> +#include <filesystem> +#include <string> + +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<void, error>; + + // 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 |
