X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=src%2Fcommon%2Futils%2Fsubprocess.h;h=79d7e3b93654621f91e8c4f7d282d78ea585674a;hb=459674d9783528f22004b28670fd231dc59ecf4a;hp=42527ee4c4facc8195c7af6060474f5ad2aca448;hpb=5877e248d5487a03e3f37ef34faca8c8247d5091;p=platform%2Fcore%2Fappfw%2Fapp-installers.git diff --git a/src/common/utils/subprocess.h b/src/common/utils/subprocess.h index 42527ee..79d7e3b 100644 --- a/src/common/utils/subprocess.h +++ b/src/common/utils/subprocess.h @@ -8,6 +8,8 @@ #include #include #include +#include +#include namespace common_installer { @@ -20,6 +22,23 @@ class Subprocess { return RunWithArgs(argv); } + template + bool RunFunc(std::function func, Args&&... args) { + if (started_) { + return false; + } + pid_ = fork(); + if (pid_ == 0) { + exit(func(std::forward(args)...)); + return false; + } else if (pid_ == -1) { + return false; + } else { + started_ = true; + return true; + } + } + bool RunWithArgs( const std::vector& args = std::vector()); int Wait();