]> git.lyx.org Git - lyx.git/blob - src/support/forkedcontr.h
fix typo that put too many include paths for most people
[lyx.git] / src / support / forkedcontr.h
1 // -*- C++ -*-
2 /**
3  * \file forkedcontr.h
4  * Copyright 2001 The LyX Team
5  * Read COPYING
6  *
7  * \author Asger Alstrup Nielsen
8  * \author Angus Leeming
9  *
10  * A class for the control of child processes launched using
11  * fork() and execvp().
12  */
13
14 #ifndef FORKEDCONTR_H
15 #define FORKEDCONTR_H
16
17 #include <list>
18 #include <vector>
19 #include "LString.h"
20 #include <sigc++/signal_system.h>
21 #include <sys/types.h> // needed for pid_t
22
23 #ifdef __GNUG__
24 #pragma interface
25 #endif
26
27 class Forkedcall;
28 class Timeout;
29
30 class ForkedcallsController : public SigC::Object {
31 public:
32         /// We need this to avoid warnings.
33         ForkedcallsController();
34         /** This d-tor should really be private, but making it public
35          *   allows egcs 1.1 to compile the class.
36          */
37         ~ForkedcallsController();
38
39         /// Get hold of the only controller that can exist inside the process.
40         static ForkedcallsController & get();
41
42         /// Add a new child process to the list of controlled processes.
43         void addCall(Forkedcall const & newcall);
44
45         /** This method is connected to the timer. Every XX ms it is called
46          *  so that we can check on the status of the children. Those that
47          *  are found to have finished are removed from the list and their
48          *  callback function is passed the final return state.
49          */
50         void timer();
51
52         /// Return a vector of the pids of all the controlled processes.
53         std::vector<pid_t> const getPIDs() const;
54
55         /// Get the command string of the process.
56         string const getCommand(pid_t) const;
57
58         /** Kill this process prematurely and remove it from the list.
59          *  The process is killed within tolerance secs.
60          *  See forkedcall.[Ch] for details.
61          */
62         void kill(pid_t, int tolerance = 5);
63
64         /// Signal emitted when the list of current child processes changes.
65         SigC::Signal0<void> childrenChanged;
66
67 private:
68         ///
69         ForkedcallsController(ForkedcallsController const &);
70
71         /// The child processes
72         typedef std::list<Forkedcall *> ListType;
73         ///
74         ListType forkedCalls;
75
76         /** The timer. Enables us to check the status of the children
77          *  every XX ms and to invoke a callback on completion.
78          */
79         Timeout * timeout_;
80 };
81
82 #endif // FORKEDCONTR_H