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
27 // pid_t isn't defined by the stdlibs that ship with MSVC.
28 #if defined (_WIN32) && defined(_MSC_VER)
38 class ForkedcallsController {
40 /// Get hold of the only controller that can exist inside the process.
41 static ForkedcallsController & get();
43 /// Add a new child process to the list of controlled processes.
44 void addCall(ForkedProcess const &);
46 /** Those child processes that are found to have finished are removed
47 * from the list and their callback function is passed the final
50 void handleCompletedProcesses();
52 /** Kill this process prematurely and remove it from the list.
53 * The process is killed within tolerance secs.
54 * See forkedcall.[Ch] for details.
56 void kill(pid_t, int tolerance = 5);
59 ForkedcallsController();
60 ForkedcallsController(ForkedcallsController const &);
61 ~ForkedcallsController();
63 typedef boost::shared_ptr<ForkedProcess> ForkedProcessPtr;
64 typedef std::list<ForkedProcessPtr> ListType;
65 typedef ListType::iterator iterator;
67 iterator find_pid(pid_t);
69 /// The child processes
75 // a wrapper for GetLastError() and FormatMessage().
76 std::string const getChildErrorMessage();
79 } // namespace support
82 #endif // FORKEDCONTR_H