4 * Copyright 2001 The LyX Team
7 * \author Asger Alstrup Nielsen
8 * \author Angus Leeming
10 * A class for the control of child processes launched using
11 * fork() and execvp().
20 #include <sigc++/signal_system.h>
21 #include <sys/types.h> // needed for pid_t
30 class ForkedcallsController : public SigC::Object {
32 /** This d-tor should really be private, but making it public
33 * allows egcs 1.1 to compile the class.
35 ~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(Forkedcall const & newcall);
43 /** This method is connected to the timer. Every XX ms it is called
44 * so that we can check on the status of the children. Those that
45 * are found to have finished are removed from the list and their
46 * callback function is passed the final return state.
50 /// Return a vector of the pids of all the controlled processes.
51 std::vector<pid_t> const getPIDs() const;
53 /// Get the command string of the process.
54 string const getCommand(pid_t) const;
56 /** Kill this process prematurely and remove it from the list.
57 * The process is killed within tolerance secs.
58 * See forkedcall.[Ch] for details.
60 void kill(pid_t, int tolerance = 5);
62 /// Signal emitted when the list of current child processes changes.
63 SigC::Signal0<void> childrenChanged;
66 /// Can't create multiple instances of ForkedcallsController.
67 ForkedcallsController();
69 ForkedcallsController(ForkedcallsController const &);
71 /// The child processes
72 typedef std::list<Forkedcall *> ListType;
76 /** The timer. Enables us to check the status of the children
77 * every XX ms and to invoke a callback on completion.
82 #endif // FORKEDCONTR_H