1 // Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
2 // Use of this source code is governed by an apache-2.0 license that can be
3 // found in the LICENSE file.
5 #ifndef COMMON_UTILS_SUBPROCESS_H_
6 #define COMMON_UTILS_SUBPROCESS_H_
14 namespace common_installer {
18 explicit Subprocess(const std::string& program);
20 template<typename ...Args> bool Run(Args&&... args) {
21 std::vector<std::string> argv{std::forward<Args>(args)...};
22 return RunWithArgs(argv);
25 template <typename... Args>
26 bool RunFunc(std::function<int(Args...)> func, Args&&... args) {
32 exit(func(std::forward<Args>(args)...));
34 } else if (pid_ == -1) {
43 const std::vector<std::string>& args = std::vector<std::string>());
46 void set_uid(int uid) {
59 } // namespace common_installer
61 #endif // COMMON_UTILS_SUBPROCESS_H_