3 * \file ForkedcallsController.h
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().
16 #ifndef FORKEDCALLSCONTROLLER_H
17 #define FORKEDCALLSCONTROLLER_H
19 #include <boost/shared_ptr.hpp>
21 #ifdef HAVE_SYS_TYPES_H
22 # include <sys/types.h>
35 class ForkedcallsController {
37 /// Get hold of the only controller that can exist inside the process.
38 static ForkedcallsController & get();
40 /// Add a new child process to the list of controlled processes.
41 void addCall(ForkedProcess const &);
43 /** Those child processes that are found to have finished are removed
44 * from the list and their callback function is passed the final
47 void handleCompletedProcesses();
49 /** Kill this process prematurely and remove it from the list.
50 * The process is killed within tolerance secs.
51 * See forkedcall.[Ch] for details.
53 void kill(pid_t, int tolerance = 5);
56 ForkedcallsController();
57 ForkedcallsController(ForkedcallsController const &);
58 ~ForkedcallsController();
60 typedef boost::shared_ptr<ForkedProcess> ForkedProcessPtr;
61 typedef std::list<ForkedProcessPtr> ListType;
62 typedef ListType::iterator iterator;
64 iterator find_pid(pid_t);
66 /// The child processes
72 // a wrapper for GetLastError() and FormatMessage().
73 std::string const getChildErrorMessage();
76 } // namespace support
79 #endif // FORKEDCALLSCONTROLLER_H