aboutsummaryrefslogtreecommitdiffstats
path: root/nihil.posix/exec.cc
diff options
context:
space:
mode:
Diffstat (limited to 'nihil.posix/exec.cc')
-rw-r--r--nihil.posix/exec.cc51
1 files changed, 1 insertions, 50 deletions
diff --git a/nihil.posix/exec.cc b/nihil.posix/exec.cc
index 5bdcbf7..b4e8732 100644
--- a/nihil.posix/exec.cc
+++ b/nihil.posix/exec.cc
@@ -4,17 +4,8 @@
module;
-#include <coroutine>
#include <expected>
#include <format>
-#include <string>
-#include <utility>
-
-#include <err.h>
-#include <fcntl.h>
-#include <unistd.h>
-
-extern char **environ;
module nihil.posix;
@@ -23,47 +14,7 @@ import nihil.monad;
namespace nihil {
-fexecv::fexecv(fd &&execfd, argv &&args) noexcept
- : m_execfd(std::move(execfd))
- , m_args(std::move(args))
-{
-}
-
-auto fexecv::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))));
-}
-
-fexecv::fexecv(fexecv &&) noexcept = default;
-auto fexecv::operator=(this fexecv &, fexecv &&) noexcept -> fexecv& = default;
-
-auto execv(std::string_view path, argv &&argv)
- -> std::expected<fexecv, error>
-{
- auto file = co_await open(path, O_EXEC)
- .transform_error([&] (error cause) {
- return error(std::format("could not open {}", path),
- std::move(cause));
- });
-
- co_return fexecv(std::move(file), std::move(argv));
-}
-
-auto execvp(std::string_view file, argv &&argv)
- -> std::expected<fexecv, error>
-{
- auto execfd = find_in_path(file);
- if (!execfd)
- return std::unexpected(error(
- std::format("executable not found in path: {}", file)));
- return fexecv(std::move(*execfd), std::move(argv));
-}
-
-auto shell(std::string_view const &command)
- -> std::expected<fexecv, error>
+auto shell(std::string_view const &command) -> std::expected<base_executor_type, error>
{
return execl("/bin/sh", "sh", "-c", command);
}