/* * Copyright © 2013 Canonical Ltd. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License version 3, * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . * * Authored by: Thomas Voß */ #ifndef CORE_POSIX_EXEC_H_ #define CORE_POSIX_EXEC_H_ #include #include #include #include #include #include namespace core { namespace posix { enum class RedirectFlags; /** * @brief exec execve's the executable with the provided arguments and environment. * @throws std::system_error in case of errors. * @param fn The executable to run. * @param argv Vector of command line arguments * @param env Environment that the new process should run under * @param flags Specifies which standard streams should be redirected. * @return An instance of ChildProcess corresponding to the newly exec'd process. */ CORE_POSIX_DLL_PUBLIC ChildProcess exec(const std::string& fn, const std::vector& argv, const std::map& env, const StandardStream& flags); /** * @brief exec execve's the executable with the provided arguments and environment. * @throws std::system_error in case of errors. * @param fn The executable to run. * @param argv Vector of command line arguments * @param env Environment that the new process should run under * @param flags Specifies which standard streams should be redirected. * @param child_setup Function to run in the child just before exec(). * @return An instance of ChildProcess corresponding to the newly exec'd process. */ CORE_POSIX_DLL_PUBLIC ChildProcess exec(const std::string& fn, const std::vector& argv, const std::map& env, const StandardStream& flags, const std::function& child_setup); } } #endif // CORE_POSIX_EXEC_H_