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().
19 #include <boost/shared_ptr.hpp>
21 #include <sys/types.h> // needed for pid_t
33 class ForkedcallsController {
35 /// Get hold of the only controller that can exist inside the process.
36 static ForkedcallsController & get();
38 /// Add a new child process to the list of controlled processes.
39 void addCall(ForkedProcess const &);
41 /** Those child processes that are found to have finished are removed
42 * from the list and their callback function is passed the final
45 void handleCompletedProcesses();
47 /** Kill this process prematurely and remove it from the list.
48 * The process is killed within tolerance secs.
49 * See forkedcall.[Ch] for details.
51 void kill(pid_t, int tolerance = 5);
54 ForkedcallsController();
55 ForkedcallsController(ForkedcallsController const &);
56 ~ForkedcallsController();
58 typedef boost::shared_ptr<ForkedProcess> ForkedProcessPtr;
59 typedef std::list<ForkedProcessPtr> ListType;
60 typedef ListType::iterator iterator;
62 iterator find_pid(pid_t);
64 /// The child processes
70 // a wrapper for GetLastError() and FormatMessage().
71 std::string const getChildErrorMessage();
74 } // namespace support
77 #endif // FORKEDCONTR_H