/* Copyright (c) 2017 Microsoft Corporation. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Author: Jared Roesch */ #pragma once #include #include #include #include "library/handle.h" #include "util/buffer.h" #include "library/pipe.h" namespace lean { enum stdio { INHERIT, PIPED, NUL, }; struct child { virtual ~child() {}; virtual handle_ref get_stdin() = 0; virtual handle_ref get_stdout() = 0; virtual handle_ref get_stderr() = 0; virtual unsigned wait() = 0; }; class process { std::string m_proc_name; buffer m_args; optional m_stdout; optional m_stdin; optional m_stderr; optional m_cwd; std::unordered_map> m_env; public: process(process const & proc) = default; process(std::string exe_name); process & arg(std::string arg_str); process & set_stdin(stdio cfg); process & set_stdout(stdio cfg); process & set_stderr(stdio cfg); process & set_cwd(std::string const & cwd); process & set_env(std::string const & var, optional const & val); std::shared_ptr spawn(); void run(); }; }