4 #include <Poco/Thread.h>
5 #include <Poco/Process.h>
6 #include <Poco/TemporaryFile.h>
14 : outPipe(), errPipe(), outInputStream(outPipe), errInputStream(errPipe), outStream(), errStream(),
23 Poco::File inputStreamFile(inputStreamFileName);
24 if (inputStreamFile.exists())
25 inputStreamFile.remove();
35 if (homeDir != homeDir_)
40 if (!starterFile.exists())
43 starterPath.createDirectories();
45 std::ofstream ofs(starterFile.path().c_str(), std::fstream::trunc);
49 starterFile.setExecutable(
true);
66 inputStreamFileName = Poco::TemporaryFile::tempName();
68 std::fstream fs(inputStreamFileName.c_str(), std::fstream::out|std::fstream::trunc|std::fstream::binary);
72 Poco::Process::Args
args={
cmd, inputStreamFileName};
73 Poco::ProcessHandle ph = Poco::Process::launch(
getStarterFullName(), args, homeDir, 0, &outPipe, &errPipe, env);
84 outInputStream >> outStream.rdbuf();
85 errInputStream >> errStream.rdbuf();
90 waitpid(pid, &status, 0);
97 if (WIFEXITED(status))
103 outInputStream >> outStream.rdbuf();
104 errInputStream >> errStream.rdbuf();
107 Poco::File inputStreamFile(inputStreamFileName);
108 if (inputStreamFile.exists())
109 inputStreamFile.remove();
112 return static_cast<unsigned int>(WEXITSTATUS(status));
119 return scriptFile.exists();
125 return scriptFile.canExecute();