using std::endl;
using std::find_if;
using std::string;
-using std::vector;
#ifndef CXX_GLOBAL_CSTD
using std::strerror;
timeout_->start();
forkedCalls.push_back(newcall.clone().release());
- childrenChanged();
}
// Check the list and, if there is a stopped child, emit the signal.
void ForkedcallsController::timer()
{
- ListType::size_type start_size = forkedCalls.size();
-
ListType::iterator it = forkedCalls.begin();
ListType::iterator end = forkedCalls.end();
while (it != end) {
if (!forkedCalls.empty() && !timeout_->running()) {
timeout_->start();
}
-
- if (start_size != forkedCalls.size())
- childrenChanged();
-}
-
-
-// Return a vector of the pids of all the controlled processes.
-vector<pid_t> const ForkedcallsController::getPIDs() const
-{
- vector<pid_t> pids;
-
- if (forkedCalls.empty())
- return pids;
-
- pids.resize(forkedCalls.size());
-
- vector<pid_t>::iterator vit = pids.begin();
- for (ListType::const_iterator lit = forkedCalls.begin();
- lit != forkedCalls.end(); ++lit, ++vit) {
- *vit = (*lit)->pid();
- }
-
- std::sort(pids.begin(), pids.end());
- return pids;
-}
-
-
-// Get the command string of the process.
-string const ForkedcallsController::getCommand(pid_t pid) const
-{
- ListType::const_iterator it =
- find_if(forkedCalls.begin(), forkedCalls.end(),
- lyx::compare_memfun(&Forkedcall::pid, pid));
-
- if (it == forkedCalls.end())
- return string();
-
- return (*it)->command();
}
#ifndef FORKEDCONTR_H
#define FORKEDCONTR_H
-#include <boost/signals/signal0.hpp>
-#include <boost/signals/trackable.hpp>
-
#include <sys/types.h> // needed for pid_t
#include <list>
-#include <vector>
class Timeout;
class ForkedProcess;
-class ForkedcallsController : public boost::signals::trackable {
+class ForkedcallsController {
public:
- /// We need this to avoid warnings.
- ForkedcallsController();
- /** This d-tor should really be private, but making it public
- * allows egcs 1.1 to compile the class.
- */
- ~ForkedcallsController();
-
/// Get hold of the only controller that can exist inside the process.
static ForkedcallsController & get();
/// Add a new child process to the list of controlled processes.
void addCall(ForkedProcess const &);
- /** This method is connected to the timer. Every XX ms it is called
- * so that we can check on the status of the children. Those that
- * are found to have finished are removed from the list and their
- * callback function is passed the final return state.
- */
- void timer();
-
- /// Return a vector of the pids of all the controlled processes.
- std::vector<pid_t> const getPIDs() const;
-
- /// Get the command string of the process.
- std::string const getCommand(pid_t) const;
-
/** Kill this process prematurely and remove it from the list.
* The process is killed within tolerance secs.
* See forkedcall.[Ch] for details.
*/
void kill(pid_t, int tolerance = 5);
- /// Signal emitted when the list of current child processes changes.
- boost::signal0<void> childrenChanged;
-
private:
- ///
+ ForkedcallsController();
ForkedcallsController(ForkedcallsController const &);
+ ~ForkedcallsController();
+
+ /** This method is connected to the timer. Every XX ms it is called
+ * so that we can check on the status of the children. Those that
+ * are found to have finished are removed from the list and their
+ * callback function is passed the final return state.
+ */
+ void timer();
/// The child processes
typedef std::list<ForkedProcess *> ListType;