]> git.lyx.org Git - lyx.git/blobdiff - src/support/syscall.C
small changes read ChangeLog
[lyx.git] / src / support / syscall.C
index 8b18c28704b51bdf7fe78431d27c2bdf49b8537e..8086ab73b2af2bf511406455bebe0e12666a68a1 100644 (file)
@@ -4,20 +4,23 @@
 #pragma implementation
 #endif
 
-#include <errno.h>
+#include <cerrno>
 #include <sys/types.h>
 #include <sys/wait.h>
-#include <signal.h>
+#include <csignal>
 #include <cstdlib>
-#include <cstdio>
 #include <unistd.h>
 #include "debug.h"
 #include "syscall.h"
 #include "syscontr.h"
 #include "support/lstrings.h"
+#include "support/lyxlib.h"
+
+using std::endl;
+
 
 Systemcalls::Systemcalls() {
-       pid = (pid_t) 0; // No child yet
+       pid = 0; // No child yet
 }
 
 Systemcalls::Systemcalls(Starttype how, string const & what, Callbackfct cback)
@@ -25,7 +28,7 @@ Systemcalls::Systemcalls(Starttype how, string const & what, Callbackfct cback)
        start   = how;
        command = what;
        cbk     = cback;
-       pid     = (pid_t) 0;
+       pid     = static_cast<pid_t>(0);
        retval  = 0;
        startscript();
 }
@@ -34,7 +37,7 @@ Systemcalls::~Systemcalls() {
 #if 0
        // If the child is alive, we have to brutally kill it
        if (getpid() != 0) {
-               ::kill(getpid(), SIGKILL);
+               lyx::kill(getpid(), SIGKILL);
        }
 #endif
 }
@@ -73,12 +76,12 @@ int Systemcalls::startscript() {
        return retval;
 }
 
-void Systemcalls::kill(int tolerance) {
+void Systemcalls::kill(int /*tolerance*/) {
        if (getpid() == 0) {
                lyxerr << "LyX: Can't kill non-existing process." << endl;
                return;
        }
-       int ret = ::kill(getpid(), SIGHUP);
+       int ret = lyx::kill(getpid(), SIGHUP);
        bool wait_for_death = true;
        if (ret != 0) {
                if (errno == ESRCH) {
@@ -92,9 +95,10 @@ void Systemcalls::kill(int tolerance) {
                // Here, we should add the PID to a list of
                // waiting processes to kill if they are not
                // dead without tolerance seconds
-#ifdef WITH_WARNINGS
-#warning Implement this using the timer of the singleton systemcontroller (Asger)
-#endif
+
+               // CHECK Implement this using the timer of
+               // the singleton systemcontroller (Asger)
+
        }
 }
 
@@ -147,15 +151,19 @@ pid_t Systemcalls::fork()
                int  index = 0;
                bool more;
                do {
+                       childcommand = frontStrip(childcommand);
                        if (syscmd == 0) {
                                syscmd = new char[childcommand.length() + 1];
                                childcommand.copy(syscmd, childcommand.length());
                                syscmd[childcommand.length()] = '\0';
                        }
+                       if (!childcommand.empty()) {
                        char * tmp = new char[childcommand.length() + 1];
                        childcommand.copy(tmp, childcommand.length());
                        tmp[childcommand.length()] = '\0';
                        argv[index++] = tmp;
+                       }
+                       
                        // reinit
                        more = !rest.empty();
                        if (more) 
@@ -183,7 +191,7 @@ int Systemcalls::startscript(Starttype how, string const & what,
        start   = how;
        command = what;
        cbk     = cback;
-       pid     = (pid_t) 0; // yet no child
+       pid     = static_cast<pid_t>(0); // yet no child
        retval  = 0;
         return startscript();
 }
@@ -205,11 +213,11 @@ void back(string cmd, int retval)
 }
 
 
-int main(int, char**)
+int main(int, char **)
 {
        
        SystemcallsSingletoncontroller::Startcontroller starter; 
-       SystemcallsSingletoncontroller *contr=starter.GetController();
+       SystemcallsSingletoncontroller *contr= starter.GetController();
        
        Systemcalls one(Systemcalls::System, "ls -ltag", back);
        Systemcalls two(Systemcalls::Wait, "ls -ltag", back);