Files
doos/src/sandbox.hpp
T

28 lines
636 B
C++
Raw Normal View History

#pragma once
#include <string>
#include <vector>
#include "container.hpp"
#include "util.hpp"
namespace doos {
// Runs a command inside a container: starts the namespaces if the container is
// stopped, joins them if it is already running. Returns the command's exit code.
class Sandbox {
public:
Sandbox(Container container, std::vector<std::string> command)
: container_(std::move(container)), command_(std::move(command)) {}
int run();
private:
int start(FileLock& lock);
int join(pid_t initPid, FileLock& lock);
Container container_;
std::vector<std::string> command_;
};
} // namespace doos