]> git.lyx.org Git - lyx.git/blobdiff - src/support/forkedcontr.h
Detect mode_t for safe use of chmod, and for scons/msvc
[lyx.git] / src / support / forkedcontr.h
index 8768015be9dfed075934fce2347fdc7c92ab249c..7f55c798d06e15bfdcdc77b045a995e5c286c5fd 100644 (file)
 #define FORKEDCONTR_H
 
 #include <boost/shared_ptr.hpp>
-#include <csignal>
-//#include <sys/types.h> // needed for pid_t
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
 #include <list>
+#include <string>
 #include <vector>
 
+
 namespace lyx {
 namespace support {
 
@@ -32,38 +37,21 @@ public:
        /// Get hold of the only controller that can exist inside the process.
        static ForkedcallsController & get();
 
-       /// Are there any completed child processes to be cleaned-up after?
-       bool processesCompleted() const { return current_child != -1; }
+       /// Add a new child process to the list of controlled processes.
+       void addCall(ForkedProcess const &);
 
        /** Those child processes that are found to have finished are removed
         *  from the list and their callback function is passed the final
         *  return state.
-        */
+        */
        void handleCompletedProcesses();
 
-       /// Add a new child process to the list of controlled processes.
-       void addCall(ForkedProcess const &);
-
        /** Kill this process prematurely and remove it from the list.
         *  The process is killed within tolerance secs.
         *  See forkedcall.[Ch] for details.
         */
        void kill(pid_t, int tolerance = 5);
 
-       struct Data {
-               Data() : pid(0), status(0) {}
-               pid_t pid;
-               int status;
-       };
-
-       /** These data are used by the SIGCHLD handler to populate a list
-        *  of child processes that have completed and been reaped.
-        *  The associated signals are then emitted within the main LyX
-        *  event loop.
-        */
-       std::vector<Data> reaped_children;
-       sig_atomic_t current_child;
-
 private:
        ForkedcallsController();
        ForkedcallsController(ForkedcallsController const &);
@@ -77,11 +65,14 @@ private:
 
        /// The child processes
        ListType forkedCalls;
-
-       /// Used to block SIGCHLD signals.
-       sigset_t newMask, oldMask;
 };
 
+
+#if defined(_WIN32)
+// a wrapper for GetLastError() and FormatMessage().
+std::string const getChildErrorMessage();
+#endif
+
 } // namespace support
 } // namespace lyx