]> git.lyx.org Git - lyx.git/blobdiff - src/support/ForkedCalls.cpp
abdel likes short code
[lyx.git] / src / support / ForkedCalls.cpp
index dcc2c3dd3428cdf975cfe87e9f4e9a36d59e3678..0768652cfb744d2a4a27b1d9ea41e7705bbd7519 100644 (file)
@@ -108,6 +108,9 @@ ForkedProcess::ForkedProcess()
 {}
 
 
+bool ForkedProcess::IAmAChild = false;
+
+
 void ForkedProcess::emitSignal()
 {
        if (signal_.get()) {
@@ -123,6 +126,10 @@ int ForkedProcess::run(Starttype type)
        pid_ = generateChild();
        if (pid_ <= 0) { // child or fork failed.
                retval_ = 1;
+               if (pid_ == 0)
+                       //we also do this in fork(), too, but maybe someone will try
+                       //to bypass that
+                       IAmAChild = true; 
                return retval_;
        }
 
@@ -184,6 +191,18 @@ void ForkedProcess::kill(int tol)
 }
 
 
+pid_t ForkedProcess::fork() {
+#if !defined (HAVE_FORK)
+       return -1;
+#else
+       pid_t pid = ::fork();
+       if (pid == 0)
+               IAmAChild = true;
+       return pid;
+#endif
+}
+
+
 // Wait for child process to finish. Returns returncode from child.
 int ForkedProcess::waitForChild()
 {