Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
Loading...
Searching...
No Matches
freebsd-jail.hh
Go to the documentation of this file.
1#pragma once
3
4#include "nix/util/types.hh"
5
6#include <filesystem>
7
8namespace nix {
9
10class AutoRemoveJail
11{
12 static constexpr int INVALID_JAIL = -1;
13public:
14 int jid = INVALID_JAIL;
15 std::vector<std::filesystem::path> childrenMounts;
16 AutoRemoveJail() = default;
17 AutoRemoveJail(int jid);
18 AutoRemoveJail(const AutoRemoveJail &) = delete;
19 AutoRemoveJail & operator=(const AutoRemoveJail &) = delete;
20
21 AutoRemoveJail(AutoRemoveJail && other) noexcept
22 : jid(other.jid)
23 {
24 other.cancel();
25 }
26
27 AutoRemoveJail & operator=(AutoRemoveJail && other) noexcept
28 {
29 swap(*this, other);
30 return *this;
31 }
32
33 friend void swap(AutoRemoveJail & lhs, AutoRemoveJail & rhs) noexcept
34 {
35 using std::swap;
36 swap(lhs.jid, rhs.jid);
37 }
38
39 operator int() const
40 {
41 return jid;
42 }
43
44 ~AutoRemoveJail();
45
52 void remove();
53
57 void cancel() noexcept;
58};
59
60} // namespace nix
void cancel() noexcept
Definition freebsd-jail.cc:58
void remove()
Definition freebsd-jail.cc:21