]> git.lyx.org Git - lyx.git/blobdiff - src/support/ForkedCalls.h
Fix C++11 test
[lyx.git] / src / support / ForkedCalls.h
index 0a226fcb7c933bb3a2270cec6e61e43a61a8b305..529f5c6861082a56b763108818d028939626d0b0 100644 (file)
 #ifndef FORKEDCALLS_H
 #define FORKEDCALLS_H
 
-#include <boost/shared_ptr.hpp>
+#include "support/shared_ptr.h"
+#include "support/strfwd.h"
 #include <boost/signal.hpp>
 
 #ifdef HAVE_SYS_TYPES_H
 # include <sys/types.h>
 #endif
 
-#include <string>
-
 namespace lyx {
 namespace support {
 
@@ -41,9 +40,9 @@ public:
        ///
        virtual ~ForkedProcess() {}
        ///
-       virtual boost::shared_ptr<ForkedProcess> clone() const = 0;
+       virtual shared_ptr<ForkedProcess> clone() const = 0;
 
-       /** A SignalType signal is can be emitted once the forked process
+       /** A SignalType signal can be emitted once the forked process
         *  has finished. It passes:
         *  the PID of the child and;
         *  the return value from the child.
@@ -62,7 +61,7 @@ public:
         *
         *  It doesn't matter if the slot disappears, SigC takes care of that.
         */
-       typedef boost::shared_ptr<SignalType> SignalTypePtr;
+       typedef shared_ptr<SignalType> SignalTypePtr;
 
        /** Invoking the following methods makes sense only if the command
         *  is running asynchronously!
@@ -97,12 +96,21 @@ public:
         */
        void kill(int tolerance = 5);
 
+       /// Returns true if this is a child process
+       static bool iAmAChild() { return IAmAChild; }
+
 protected:
        /** Spawn the child process.
         *  Returns returncode from child.
         */
        int run(Starttype type);
 
+       /// implement our own version of fork()
+       /// it just returns -1 if ::fork() is not defined
+       /// otherwise, it forks and sets the global child-process
+       /// boolean IAmAChild
+       pid_t fork();
+
        /// Callback function
        SignalTypePtr signal_;
 
@@ -118,12 +126,15 @@ private:
        /// generate child in background
        virtual int generateChild() = 0;
 
+       ///
+       static bool IAmAChild;
+
        /// Wait for child process to finish. Updates returncode from child.
        int waitForChild();
 };
 
 
-/* 
+/** 
  * An instance of class ForkedCall represents a single child process.
  *
  * Class ForkedCall uses fork() and execvp() to lauch the child process.
@@ -139,8 +150,10 @@ private:
 class ForkedCall : public ForkedProcess {
 public:
        ///
-       virtual boost::shared_ptr<ForkedProcess> clone() const {
-               return boost::shared_ptr<ForkedProcess>(new ForkedCall(*this));
+       ForkedCall(std::string const & path = empty_string());
+       ///
+       virtual shared_ptr<ForkedProcess> clone() const {
+               return shared_ptr<ForkedProcess>(new ForkedCall(*this));
        }
 
        /** Start the child process.
@@ -163,6 +176,8 @@ public:
 private:
        ///
        virtual int generateChild();
+       ///
+       std::string cmd_prefix_;
 };