]> git.lyx.org Git - lyx.git/blobdiff - src/support/syscall.C
export patch from Dekel
[lyx.git] / src / support / syscall.C
index cea3980137568f37effce1f5e9967f7b68072582..3630103758f1766d1758c53a766e2ef4e8421537 100644 (file)
@@ -16,6 +16,9 @@
 #include "support/lstrings.h"
 #include "support/lyxlib.h"
 
+using std::endl;
+
+
 Systemcalls::Systemcalls() {
        pid = 0; // No child yet
 }
@@ -47,6 +50,7 @@ int Systemcalls::startscript() {
        retval = 0;
        switch (start) {
        case System: 
+       case SystemDontWait:
                retval = system(command.c_str());
                callback();
                break;
@@ -92,9 +96,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 +152,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) 
@@ -185,6 +194,29 @@ int Systemcalls::startscript(Starttype how, string const & what,
        cbk     = cback;
        pid     = static_cast<pid_t>(0); // yet no child
        retval  = 0;
+
+       if (how == SystemDontWait) {
+#ifndef __EMX__
+               command += " &";
+#else
+               // OS/2 cmd.exe has another use for '&'
+               // This is not NLS safe, but it's OK, I think.
+               string sh = OnlyFilename(GetEnvPath("EMXSHELL"));
+               if (sh.empty()) {
+                       // COMSPEC is set, unless user unsets 
+                       sh = OnlyFilename(GetEnvPath("COMSPEC"));
+                       if (sh.empty())
+                               sh = "cmd.exe";
+               }
+               sh = lowercase(sh);
+               if (contains(sh, "cmd.exe")
+                   || contains(sh, "4os2.exe"))
+                       command = "start /min/n " + command;
+               else
+                       command += " &";
+#endif
+       }
+
         return startscript();
 }