blob: ca036a190f575a3611f8fc407dd28186c3680290 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
|