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
32 class ForkedcallsController {
34 /// Get hold of the only controller that can exist inside the process.
35 static ForkedcallsController & get();
37 /// Add a new child process to the list of controlled processes.
38 void addCall(ForkedProcess const &);
40 /** Those child processes that are found to have finished are removed
41 * from the list and their callback function is passed the final
44 void handleCompletedProcesses();
46 /** Kill this process prematurely and remove it from the list.
47 * The process is killed within tolerance secs.
48 * See forkedcall.[Ch] for details.
50 void kill(pid_t, int tolerance = 5);
53 ForkedcallsController();
54 ForkedcallsController(ForkedcallsController const &);
55 ~ForkedcallsController();
57 typedef boost::shared_ptr<ForkedProcess> ForkedProcessPtr;
58 typedef std::list<ForkedProcessPtr> ListType;
59 typedef ListType::iterator iterator;
61 iterator find_pid(pid_t);
63 /// The child processes
69 // a wrapper for GetLastError() and FormatMessage().
70 std::string const getChildErrorMessage();
73 } // namespace support
76 #endif // FORKEDCONTR_H