1 /******************************************************************************
3 * Copyright (C) 2012 Icinga Development Team (http://www.icinga.org/) *
5 * This program is free software; you can redistribute it and/or *
6 * modify it under the terms of the GNU General Public License *
7 * as published by the Free Software Foundation; either version 2 *
8 * of the License, or (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the Free Software Foundation *
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. *
18 ******************************************************************************/
27 * The result of a Process task.
33 double ExecutionStart;
40 * A process task. Executes an external application and returns the exit
41 * code and console output.
45 class I2_BASE_API Process : public AsyncTask<Process, ProcessResult>
48 typedef shared_ptr<Process> Ptr;
49 typedef weak_ptr<Process> WeakPtr;
51 static const deque<Process::Ptr>::size_type MaxTasksPerThread = 512;
53 Process(const vector<String>& arguments, const Dictionary::Ptr& extraEnvironment = Dictionary::Ptr());
55 static vector<String> SplitCommand(const Value& command);
57 vector<String> m_Arguments;
58 Dictionary::Ptr m_ExtraEnvironment;
65 stringstream m_OutputStream;
67 ProcessResult m_Result;
69 virtual void Run(void);
71 static boost::mutex m_Mutex;
72 static deque<Process::Ptr> m_Tasks;
74 static condition_variable m_CV;
77 static Timer::Ptr m_StatusTimer;
85 static void WorkerThreadProc(void);
87 static void WorkerThreadProc(int taskFd);
89 static void StatusTimerHandler(void);
95 static boost::once_flag m_ThreadOnce;
96 static void Initialize(void);
101 #endif /* PROCESS_H */