4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Asger Alstrup Nielsen
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS
12 * A class for the control of child processes launched using
13 * fork() and execvp().
21 #include <boost/signals/signal0.hpp>
22 #include <boost/signals/trackable.hpp>
24 #include <sys/types.h> // needed for pid_t
32 class ForkedcallsController : public boost::signals::trackable {
34 /// We need this to avoid warnings.
35 ForkedcallsController();
36 /** This d-tor should really be private, but making it public
37 * allows egcs 1.1 to compile the class.
39 ~ForkedcallsController();
41 /// Get hold of the only controller that can exist inside the process.
42 static ForkedcallsController & get();
44 /// Add a new child process to the list of controlled processes.
45 void addCall(ForkedProcess const &);
47 /** This method is connected to the timer. Every XX ms it is called
48 * so that we can check on the status of the children. Those that
49 * are found to have finished are removed from the list and their
50 * callback function is passed the final return state.
54 /// Return a vector of the pids of all the controlled processes.
55 std::vector<pid_t> const getPIDs() const;
57 /// Get the command string of the process.
58 string const getCommand(pid_t) const;
60 /** Kill this process prematurely and remove it from the list.
61 * The process is killed within tolerance secs.
62 * See forkedcall.[Ch] for details.
64 void kill(pid_t, int tolerance = 5);
66 /// Signal emitted when the list of current child processes changes.
67 boost::signal0<void> childrenChanged;
71 ForkedcallsController(ForkedcallsController const &);
73 /// The child processes
74 typedef std::list<ForkedProcess *> ListType;
78 /** The timer. Enables us to check the status of the children
79 * every XX ms and to invoke a callback on completion.
84 #endif // FORKEDCONTR_H