/* * This source code is released into the public domain. */ module; /* * Exec providers, mostly used for spawn(). */ #include #include #include "nihil.hh" export module nihil.posix:exec; import nihil.error; import :execv; import :fexecv; import :argv; import :fd; namespace nihil { /* * The lowest-level executor type, which is returned by other executors. * Prefer fexecve() if it's available, otherwise use execve(). */ #ifdef NIHIL_HAVE_FEXECVE using base_executor_type = fexecv; #else using base_executor_type = execv; #endif /* * execl: equivalent to execv, except the arguments are passed as a * variadic pack of string-like objects. */ export [[nodiscard]] auto execl(std::string_view path, auto &&...args) -> std::expected { return execv(path, argv({std::string_view(args)...})); } /* * shell: run the process by invoking /bin/sh -c with the single argument, * equivalent to system(3). */ export [[nodiscard]] auto shell(std::string_view const &command) -> std::expected; } // namespace nihil