diff options
| author | Lexi Winter <lexi@le-fay.org> | 2025-07-01 17:07:04 +0100 |
|---|---|---|
| committer | Lexi Winter <lexi@le-fay.org> | 2025-07-01 17:07:04 +0100 |
| commit | 2e2d1bd3b6c7776b77c33b94f30ead89367a71e6 (patch) | |
| tree | 54d37ffadf8e677938d9b7a28e4e9b71be1e75c1 /nihil.posix/fexecv.ccm | |
| parent | 36427c0966faa7aecd586b397ed9b845f18172f5 (diff) | |
| download | nihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.gz nihil-2e2d1bd3b6c7776b77c33b94f30ead89367a71e6.tar.bz2 | |
add nihil.std
Diffstat (limited to 'nihil.posix/fexecv.ccm')
| -rw-r--r-- | nihil.posix/fexecv.ccm | 58 |
1 files changed, 0 insertions, 58 deletions
diff --git a/nihil.posix/fexecv.ccm b/nihil.posix/fexecv.ccm deleted file mode 100644 index 4001726..0000000 --- a/nihil.posix/fexecv.ccm +++ /dev/null @@ -1,58 +0,0 @@ -// This source code is released into the public domain. -module; - -#include <expected> -#include <string> - -#include "nihil.hh" - -export module nihil.posix:fexecv; - -import nihil.error; -import :argv; -import :executor; -import :fd; - -namespace nihil { - -#ifdef NIHIL_HAVE_FEXECVE - -/* - * 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 - : m_execfd(std::move(execfd)) - , m_args(std::move(args)) - { - } - - [[nodiscard]] auto exec(this fexecv &self) -> std::expected<void, error> - { - ::fexecve(self.m_execfd.get(), self.m_args.data(), environ); - return std::unexpected(error("fexecve failed", error(std::errc(errno)))); - } - - // Movable - fexecv(fexecv &&) noexcept = default; - auto operator=(this fexecv &, fexecv &&) noexcept -> fexecv & = default; - - // 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; -}; - -#endif // NIHIL_HAVE_FEXECVE - -} // namespace nihil |
