]> git.lyx.org Git - features.git/commitdiff
We don't currently use fork anywhere (or if we do it's by mistake!), so
authorAngus Leeming <leeming@lyx.org>
Sat, 16 Feb 2002 12:39:47 +0000 (12:39 +0000)
committerAngus Leeming <leeming@lyx.org>
Sat, 16 Feb 2002 12:39:47 +0000 (12:39 +0000)
this patch strips down syscall.[Ch] so it now contains only the system
call interface. This interface is very, very simple! At the same time
I've taken the opportunity to remove syscontr.[Ch] and syssingleton.C,
again because they aren't used.

The rest of the changes are due to the change of name in the
Systemcall::Starttype enum. System is now Wait, and SystemDontWait is DontWait

Paves the way for resurrecting a proper forked calls controller.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3553 a592a061-630c-0410-9148-cb99ea01b6c8

23 files changed:
src/ChangeLog
src/Chktex.C
src/LaTeX.C
src/LyXSendto.C
src/buffer.C
src/converter.C
src/frontends/ChangeLog
src/frontends/Liason.C
src/frontends/controllers/ChangeLog
src/frontends/controllers/ControlGraphics.C
src/frontends/controllers/ControlTexinfo.C
src/lyx_cb.C
src/mathed/ChangeLog
src/mathed/formula.C
src/support/ChangeLog
src/support/Makefile.am
src/support/filetools.C
src/support/syscall.C
src/support/syscall.h
src/support/syscontr.C [deleted file]
src/support/syscontr.h [deleted file]
src/support/syssingleton.C [deleted file]
src/vc-backend.C

index 3c00e6dccb2fcfcdde17a82276bf98ad11e5a1d6..7554898725627942f57865c5070abc9bf46ea2b2 100644 (file)
@@ -1,3 +1,20 @@
+2002-02-16  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * Chktex.C:
+       * buffer.C:
+       remove #include "support/syscall.h" as it's redundant. Always has been.
+       
+       * Chktex.C:
+       * LaTeX.C:
+       * LyXSendto.C:
+       * converter.C:
+       * lyx_cb.C:
+       * vc-backend.C:
+       change Systemcalls::System to Systemcalls::Wait and
+       change Systemcalls::SystemDontWait to Systemcalls::DontWait.
+       No change of functionality, just reflects the stripped down Systemcalls
+       class.
+
 2002-02-16  Angus Leeming  <a.leeming@ic.ac.uk>
 
        * debug.[Ch]: add a GRAPHICS type to the enum.
index 1193c7590a72eb39c9ba92f13ef25b3dd2c75a4b..74ee7ac09ac9924c1cb94b05c41230f3be561bd9 100644 (file)
@@ -26,7 +26,6 @@
 #include "support/FileInfo.h"
 #include "support/filetools.h"
 #include "support/syscall.h"
-#include "support/syscontr.h"
 #include "support/path.h"
 #include "support/lstrings.h"
 
@@ -51,7 +50,7 @@ int Chktex::run(TeXErrors &terr)
        string log = OnlyFilename(ChangeExtension(file, ".log"));
        string tmp = cmd + " -q -v0 -b0 -x " + file + " -o " + log;
         Systemcalls one;
-       int result= one.startscript(Systemcalls::System, tmp);
+       int result= one.startscript(Systemcalls::Wait, tmp);
        if (result == 0) {
                result = scanLogFile(terr);
        } else {
index 8c812a389fcb00a2d65ec9e4f3885c6cad2da1e2..1ceeda1b00ab7e9fb058ae8956f4538d6616d410 100644 (file)
@@ -25,7 +25,6 @@
 #include "debug.h"
 #include "support/lyxlib.h"
 #include "support/syscall.h"
-#include "support/syscontr.h"
 #include "support/path.h"
 #include "support/LRegex.h"
 #include "support/LSubstring.h"
@@ -360,7 +359,7 @@ int LaTeX::operator()()
        string tmp = cmd + ' ' + file + " > nul";
 #endif
         Systemcalls one;
-       return one.startscript(Systemcalls::System, tmp);
+       return one.startscript(Systemcalls::Wait, tmp);
 }
 
 
@@ -377,7 +376,7 @@ bool LaTeX::runMakeIndex(string const & f)
        string tmp = "makeindex -c -q ";
        tmp += f;
        Systemcalls one;
-       one.startscript(Systemcalls::System, tmp);
+       one.startscript(Systemcalls::Wait, tmp);
        return true;
 }
 
@@ -508,7 +507,7 @@ bool LaTeX::runBibTeX(vector<Aux_Info> const & bibtex_info)
                string tmp = "bibtex ";
                tmp += OnlyFilename(ChangeExtension(it->aux_file, string()));
                Systemcalls one;
-               one.startscript(Systemcalls::System, tmp);
+               one.startscript(Systemcalls::Wait, tmp);
        }
        // Return whether bibtex was run
        return result;
index d457dc7fa11cf4e322c6015f24d3ca7a4fabe3fd..99022c6ae100c3cbd06a68d11105a14dfb596eba 100644 (file)
@@ -95,7 +95,7 @@ void SendtoApplyCB(FL_OBJECT *, long)
     // create the .txt file in tmp_dir if this filetype is requested
     if (fl_get_button(fd_form_sendto->radio_ftype_ascii))
         buffer->writeFileAscii(fname, lyxrc.ascii_linelen);
-    Systemcalls one(Systemcalls::System, command);    
+    Systemcalls one(Systemcalls::Wait, command);    
 }
 
 
index c6a41f503c5879a883f74181b830be02ca3255d7..e888e3588ea81529d03117dfe5d4169d4a920ae8 100644 (file)
@@ -89,7 +89,6 @@
 #include "support/filetools.h"
 #include "support/path.h"
 #include "support/os.h"
-#include "support/syscall.h"
 #include "support/lyxlib.h"
 #include "support/FileInfo.h"
 #include "support/lyxmanip.h"
index d9f0f72cf76732b9c9295912372f3a47d379278b..17a5d90e19f6e7ec10ed00dc0a5c4260863db319 100644 (file)
@@ -196,7 +196,7 @@ bool Formats::view(Buffer const * buffer, string const & filename,
 
        Path p(OnlyPath(filename));
        Systemcalls one;
-       int const res = one.startscript(Systemcalls::SystemDontWait, command);
+       int const res = one.startscript(Systemcalls::DontWait, command);
 
        if (res) {
                Alert::alert(_("Cannot view file"),
@@ -645,7 +645,7 @@ bool Converters::convert(Buffer const * buffer,
                                ShowMessage(buffer, _("Executing command:"), command);
 
                        Systemcalls::Starttype type = (dummy)
-                               ? Systemcalls::SystemDontWait : Systemcalls::System;
+                               ? Systemcalls::DontWait : Systemcalls::Wait;
                        Systemcalls one;
                        int res;
                        if (conv.original_dir && buffer) {
@@ -659,7 +659,7 @@ bool Converters::convert(Buffer const * buffer,
                                string const command2 = conv.parselog +
                                        " < " + QuoteName(infile2 + ".out") +
                                        " > " + QuoteName(logfile);
-                               one.startscript(Systemcalls::System, command2);
+                               one.startscript(Systemcalls::Wait, command2);
                                if (!scanLog(buffer, command, logfile))
                                        return false;
                        }
index faf995cad87b56be9680aa6e87eaad565c6d5332..e01a81ed0c72009a4f76367885f37c200f02f03d 100644 (file)
@@ -1,3 +1,11 @@
+2002-02-16  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * Liason.C:
+       change Systemcalls::System to Systemcalls::Wait and
+       change Systemcalls::SystemDontWait to Systemcalls::DontWait.
+       No change of functionality, just reflects the stripped down Systemcalls
+       class.
+
 2002-01-14  Jean-Marc Lasgouttes  <lasgouttes@freesurf.fr>
 
        * Liason.C (printBuffer): use Buffer::filePath
index f1fe2c8dcbdf303a2a48b2b8175ea43f83579ba5..e038c8b3f357fdb65ab0ccf19a17d09fc8f1a67a 100644 (file)
@@ -134,13 +134,13 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
                        command2 += QuoteName(psname);
                        // First run dvips.
                        // If successful, then spool command
-                       res = one.startscript(Systemcalls::System, command);
+                       res = one.startscript(Systemcalls::Wait, command);
                        if (res == 0)
-                               res = one.startscript(Systemcalls::SystemDontWait,
+                               res = one.startscript(Systemcalls::DontWait,
                                                      command2);
                } else
                        // case 2
-                       res = one.startscript(Systemcalls::SystemDontWait,
+                       res = one.startscript(Systemcalls::DontWait,
                                              command + QuoteName(dviname));
                break;
 
@@ -149,7 +149,7 @@ bool printBuffer(Buffer * buffer, PrinterParams const & pp)
                command += lyxrc.print_to_file
                        + QuoteName(MakeAbsPath(pp.file_name, path));
                command += ' ' + QuoteName(dviname);
-               res = one.startscript(Systemcalls::SystemDontWait, command);
+               res = one.startscript(Systemcalls::DontWait, command);
                break;
        }
        return res == 0;
index bc13a121d20da93e14b9ac5a857acfbc8e6ba67a..f5cc9fcf9bc3471978d06229d2ed940623100f0e 100644 (file)
@@ -1,3 +1,12 @@
+2002-02-16  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * ControlGraphics.C: remove #include "support/syscall.h" as it's not
+       used.
+       * ControlTexinfo.C: 
+       change Systemcalls::System to Systemcalls::Wait and
+       No change of functionality, just reflects the stripped down Systemcalls
+       class.
+
 2002-02-06  Herbert Voss  <voss@lyx.org>
 
        * ControlGraphics.[C] (readBB): search also in
index 5b94c7b66bc9d7e4d84a36b6f025442e86676784..5c0972bfb867780b1875e85e3b32854956d7915b 100644 (file)
@@ -35,8 +35,7 @@
 #include "support/FileInfo.h"  // for FileInfo
 #include "helper_funcs.h"      // for browseFile
 #include "support/lstrings.h"
-#include "support/filetools.h" // for AddName
-#include "support/syscall.h"   // for zippedFile()
+#include "support/filetools.h" // for AddName, zippedFile
 #include "BufferView.h"
 
 using std::pair;
index 19a2291a3446f7fd9232109e94d4cc091dff6bcc..9a266a985fcce976627c0647f4e567c091f62cfa 100644 (file)
@@ -44,7 +44,7 @@ void ControlTexinfo::rescanStyles() const
 {
        // Run rescan in user lyx directory
        Path p(user_lyxdir);
-       Systemcalls one(Systemcalls::System,
+       Systemcalls one(Systemcalls::Wait,
                        LibFileSearch("scripts", "TeXFiles.sh"));
        p.pop();
 }
@@ -56,7 +56,7 @@ void ControlTexinfo::runTexhash() const
        Path p(user_lyxdir);
 
        //path to texhash through system
-       Systemcalls one(Systemcalls::System,"texhash"); 
+       Systemcalls one(Systemcalls::Wait, "texhash"); 
        p.pop();
 //     Alert::alert(_("texhash run!"), 
 //                _("rebuilding of the TeX-tree could only be successfull"),
index 4dba209bcbc6f595b01c62b569ead25dcb198027..2bbe4a334769bf137fe20e8356a72de56fa38f60 100644 (file)
@@ -537,7 +537,7 @@ void Reconfigure(BufferView * bv)
 
        // Run configure in user lyx directory
        Path p(user_lyxdir);
-       Systemcalls one(Systemcalls::System
+       Systemcalls one(Systemcalls::Wait
                        AddName(system_lyxdir, "configure"));
        p.pop();
        bv->owner()->message(_("Reloading configuration..."));
index 71840dee6437cfc8efeefdfcfedcc1c8ef55f119..75f3791ee5976d70ef53106ec63f7ce50eb6b4b2 100644 (file)
@@ -1,3 +1,8 @@
+2002-02-16  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * formula.C: change Systemcalls::System to Systemcalls::Wait and
+       No change of functionality, just reflects the stripped down Systemcalls
+       class.
 
 2002-02-08  André Pönitz <poenitz@gmx.net>
 
index 1fb6fdb7a06d1e6ce8e2a678cca5d9b7a0bdf686..19b36006ff4e80064bc57b1ff23b7c99e96bd50d 100644 (file)
@@ -60,7 +60,7 @@ namespace {
                string outfile = lyx::tempName(string(), "mathextern");
                string full =  "echo '" + data + "' | (" + cmd + ") > " + outfile;
                lyxerr << "calling: " << full << "\n";
-               Systemcalls dummy(Systemcalls::System, full, 0);
+               Systemcalls dummy(Systemcalls::Wait, full);
                string out = GetFileContents(outfile);
                lyx::unlink(outfile);
                lyxerr << "result: '" << out << "'\n";
index 3e5c6badeda2f16af20688a86276f5668bbf2317..d431f31fa75f25f6cc1d7f8c53636259b4b99a3b 100644 (file)
@@ -1,3 +1,12 @@
+2002-02-16  Angus Leeming  <a.leeming@ic.ac.uk>
+
+       * syscontr.[Ch]:
+       * syssingleton.C: files removed.
+
+       * syscall.[Ch]: remove the forked calls interface, as nothing, nowhere
+       uses it. Strip down the Systemcalls interface to make it brutally
+       obvious how unsophisticated it is.
+
 2002-02-08  Herbert Voss  <voss@perce.de>
 
        * filetools.C: (getExtFromContents) adding TGIF-format
index 8338d049958d1b2c912d3fca4de9ddef70610e2d..319d68fd9e5542965230d0f273f81c79c40b014a 100644 (file)
@@ -65,9 +65,6 @@ libsupport_la_SOURCES = \
        sstream.h \
        $(REGEX) syscall.C \
        syscall.h \
-       syscontr.C \
-       syscontr.h \
-       syssingleton.C \
        tempname.C \
        textutils.h \
        translator.h \
index a31cb981c0e3225fe017fad77d31b002f8e60ccb..c8b405d6bbe5bcc2ca7f4de55c1e0cc6656336ac 100644 (file)
@@ -1056,7 +1056,7 @@ string const unzipFile(string const & zipped_file)
     string  const tempfile = lyx::tempName(string(), file);
     // Run gunzip
     string const command = "gunzip -c "+zipped_file+" > "+tempfile;
-    Systemcalls one(Systemcalls::System, command);
+    Systemcalls one(Systemcalls::Wait, command);
     // test that command was executed successfully
     return tempfile;
 }
index 597dd362de113360e86bab3000b4741b86646ad4..9a9e1ecc547b8b1dbef0b9e8aebf8933d8d26b48 100644 (file)
+/**
+ *  \file syscall.C
+ *  Copyright 2002 the LyX Team
+ *  Read the file COPYING
+ *
+ * \author Asger Alstrup
+ *
+ * Interface cleaned up by
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ *
+ * Class Systemcalls uses "system" to launch the child process.
+ * The user can choose to wait or not wait for the process to complete, but no
+ * callback is invoked upon completion of the child.
+ *
+ * The child process is not killed when the Systemcall instance goes out of
+ * scope.
+ */
+
 #include <config.h>
 
 #ifdef __GNUG__
 #pragma implementation
 #endif
 
-#include <cerrno>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <csignal>
-#include <cstdlib>
-#include <unistd.h>
-#include "debug.h"
 #include "syscall.h"
-#include "syscontr.h"
-#include "support/lstrings.h"
-#include "support/lyxlib.h"
-#include "support/filetools.h"
-#include "support/os.h"
-
-using std::endl;
-
-#ifndef CXX_GLOBAL_CSTD
-using std::strerror;
-#endif
-
-
-Systemcalls::Systemcalls() {
-       pid = 0; // No child yet
-}
-
-Systemcalls::Systemcalls(Starttype how, string const & what, Callbackfct cback)
-{
-       startscript(how, what, cback);
-}
-
-Systemcalls::~Systemcalls() {
-#if 0
-       // If the child is alive, we have to brutally kill it
-       if (getpid() != 0) {
-               lyx::kill(getpid(), SIGKILL);
-       }
-#endif
-}
-
-// Start a childprocess
-// 
-// if child runs in background, add information to global controller.
-
-int Systemcalls::startscript() {
-       retval = 0;
-       switch (start) {
-       case System: 
-       case SystemDontWait:
-               retval = ::system(command.c_str());
-               callback();
-               break;
-       case Wait:   
-               pid = fork();
-               if (pid>0) { // Fork succesful. Wait for child
-                       waitForChild();
-                       callback();
-               } else
-                       retval = 1;
-               break;
-       case DontWait:
-               pid = fork();
-               if (pid>0) {
-                       // Now integrate into Controller
-                       SystemcallsSingletoncontroller::Startcontroller starter;
-                       SystemcallsSingletoncontroller * contr = starter.getController();
-                       // Add this to controller
-                       contr->addCall(*this);
-               } else
-                       retval = 1;
-               break;
-       }
-       return retval;
-}
-
-void Systemcalls::kill(int /*tolerance*/) {
-       if (getpid() == 0) {
-               lyxerr << "LyX: Can't kill non-existing process." << endl;
-               return;
-       }
-       int ret = lyx::kill(getpid(), SIGHUP);
-       bool wait_for_death = true;
-       if (ret != 0) {
-               if (errno == ESRCH) {
-                       // The process is already dead!
-                       wait_for_death = false;
-               } else {
-                       // Something is rotten - maybe we lost permissions?
-               }
-       }
-       if (wait_for_death) {
-               // Here, we should add the PID to a list of
-               // waiting processes to kill if they are not
-               // dead within tolerance seconds
-
-               // CHECK Implement this using the timer of
-               // the singleton systemcontroller (Asger)
-
-       }
-}
-
-
-// Wait for child process to finish. Returns returncode from child.
-void Systemcalls::waitForChild() {
-       // We'll pretend that the child returns 1 on all errorconditions.
-       retval = 1;
-       int status;
-       bool wait = true;
-       while (wait) {
-               pid_t waitrpid = waitpid(pid, &status, WUNTRACED);
-               if (waitrpid == -1) {
-                       lyxerr << "LyX: Error waiting for child:"
-                              << strerror(errno) << endl;
-                       wait = false;
-               } else if (WIFEXITED(status)) {
-                       // Child exited normally. Update return value.
-                       retval = WEXITSTATUS(status);
-                       wait = false;
-               } else if (WIFSIGNALED(status)) {
-                       lyxerr << "LyX: Child didn't catch signal "
-                              << WTERMSIG(status) 
-                              << "and died. Too bad." << endl;
-                       wait = false;
-               } else if (WIFSTOPPED(status)) {
-                       lyxerr << "LyX: Child (pid: " << pid 
-                              << ") stopped on signal "
-                              << WSTOPSIG(status) 
-                              << ". Waiting for child to finish." << endl;
-               } else {
-                       lyxerr << "LyX: Something rotten happened while "
-                               "waiting for child " << pid << endl;
-                       wait = false;
-               }
-       }
-}
+#include "os.h"
 
-
-// generate child in background
-
-pid_t Systemcalls::fork()
+Systemcalls::Systemcalls(Starttype how, string const & what)
 {
-       #ifndef __EMX__
-       pid_t cpid= ::fork();
-       if (cpid == 0) { // child
-       #endif
-               // TODO: Consider doing all of this before the fork, otherwise me
-               // might have troubles with multi-threaded access. (Baruch 20010228)
-               string childcommand(command); // copy
-               string rest = split(command, childcommand, ' ');
-               const int MAX_ARGV = 255;
-               char *syscmd = 0; 
-               char *argv[MAX_ARGV];
-               int  index = 0;
-               bool more = true;
-               while (more) {
-                       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) 
-                               rest = split(rest, childcommand, ' ');
-               }
-               argv[index] = 0;
-               // replace by command. Expand using PATH-environment-var.
-#ifndef __EMX__
-               execvp(syscmd, argv);
-               // If something goes wrong, we end up here:
-               lyxerr << "LyX: execvp(" << syscmd << ") failed: "
-                      << strerror(errno) << endl;
-       } else if (cpid < 0) { // error
-#else
-       pid_t cpid = spawnvp(P_SESSION|P_DEFAULT|P_MINIMIZE|P_BACKGROUND, syscmd, argv);
-       if (cpid < 0) { // error
-#endif
-               lyxerr << "LyX: Could not fork: "
-                      << strerror(errno) << endl;
-       } else { // parent
-               return cpid;
-       }
-       return 0;
+       startscript(how, what);
 }
 
 
 // Reuse of instance
-
-int Systemcalls::startscript(Starttype how, string const & what, 
-                             Callbackfct cback)
+int Systemcalls::startscript(Starttype how, string const & what)
 {
-       start   = how;
-       command = what;
-       cbk     = cback;
-       pid     = static_cast<pid_t>(0); // yet no child
-       retval  = 0;
+       string command = what;
 
-       if (how == SystemDontWait) {
+       if (how == DontWait) {
                if (os::shell() == os::UNIX) {
                        command += " &";
                } else {
@@ -216,41 +44,5 @@ int Systemcalls::startscript(Starttype how, string const & what,
                }
        }
 
-        return startscript();
+       return ::system(command.c_str());
 }
-
-
-
-//
-// Mini-Test-environment for script-classes
-//
-#ifdef TEST_MAIN
-#include <stdio.h>
-
-
-int SimulateTimer;
-void back(string cmd, int retval)
-{
-       ::printf("Done: %s gave %d\n", cmd.c_str(), retval);
-       SimulateTimer = 0;
-}
-
-
-int main(int, char **)
-{
-       
-       SystemcallsSingletoncontroller::Startcontroller starter; 
-       SystemcallsSingletoncontroller *contr= starter.GetController();
-       
-       Systemcalls one(Systemcalls::System, "ls -ltag", back);
-       Systemcalls two(Systemcalls::Wait, "ls -ltag", back);
-       SimulateTimer = 1;
-       Systemcalls three(Systemcalls::DontWait , "ls -ltag", back);
-       // Simulation of timer
-       while (SimulateTimer)
-               {
-                       sleep(1);
-                       contr->Timer();
-               }
-}
-#endif
index dd014ae112ca22e78711016c569db9767161d104..598fbc13dc15191324560fa1b44afb87dafccfe4 100644 (file)
@@ -1,5 +1,24 @@
 // -*- C++ -*-
-#include <sys/types.h>
+/**
+ *  \file syscall.h
+ *  Copyright 2002 the LyX Team
+ *  Read the file COPYING
+ *
+ * \author Asger Alstrup
+ *
+ * Interface cleaned up by
+ * \author Angus Leeming <a.leeming@ic.ac.uk>
+ *
+ * Class Systemcalls uses "system" to launch the child process.
+ * The user can choose to wait or not wait for the process to complete, but no
+ * callback is invoked upon completion of the child.
+ *
+ * The child process is not killed when the Systemcall instance goes out of
+ * scope.
+ */
+
+#ifndef SYSCALL_H
+#define SYSCALL_H
 
 #include "LString.h"
 
 #pragma interface
 #endif
 
-/**
-  This class can be used to start child processes.
-
-  An instance of the class represents a child process.
-  You should use this class if you need to start an external program in LyX.
-  If you wish, you can have a callback function executed when the process
-  finishes.
-  You can chose between three kinds of child processes:
-  1) System processes, which are initiated with the "system" call,
-     where the main thread waits for the system call to return.
-  2) Wait for child process, which are forked, but the main thread waits for
-     the child to end.
-  3) Don't wait, which are forked, but the main thread is not stopped.
-     The process can be considered a background process.
-     A timer will make sure that any callback function is called when
-     the child process ends.
-
-  Notice that any callback associated with a process is called whatever
-  the kind of child process.
-  */
 class Systemcalls {
 public:
        ///
        enum Starttype {
-               /// Uses system() which uses /bin/sh
-               System,
-               /// Uses system() which uses /bin/sh
-               SystemDontWait,
-               /// Uses fork() and execvp()
+               ///
                Wait,
-               /// Uses fork() and execvp()
+               ///
                DontWait
        };
        
-       /// Callback function gets commandline and return value from child
-       typedef void (*Callbackfct)(string cmd, int retval);
-       
        ///
-       Systemcalls();
+       Systemcalls() {}
        
        /** Generate instance and start child process.
-           The string "what" contains a commandline with arguments separated 
-           by spaces.
-           When the requested program finishes, the callback-function is 
-           called with the commandline and the return value from the program.
-           The instance is automatically added to a timer check if starttype 
-           is DontWait (i.e. background execution). When a background child
-           finishes, the timer check will automatically call the callback
-           function.
-       */
-       Systemcalls(Starttype how, string const & what, Callbackfct call = 0);
-       
-       ///
-       ~Systemcalls();
-       
-       /** Start childprocess. "what" contains a command at system level.
-           This is for reuse of the Systemcalls instance.
-       */
-       int startscript(Starttype how, string const & what, 
-                       Callbackfct call = 0);
-       
-       /** gets PID of childprocess.
-           Used by timer
-       */
-       pid_t getpid() { return pid; }
-       
-       /// Start callback
-       void callback() { if (cbk) cbk(command, retval); }
-
-       /** Set return value. Used by timer */
-       void setRetValue(int r) { retval = r; }
-
-       /** Kill child prematurely.
-           First, a SIGHUP is sent to the child.
-           If that does not end the child process within "tolerance"
-           seconds, the SIGKILL signal is sent to the child.
-           When the child is dead, the callback is called.
-       */
-       void kill(int tolerance = 5);
-
-private:
-       /// Type of execution: system, wait for child or background
-       Starttype start;
-
-       /// Callback function
-       Callbackfct cbk;
-
-       /// Commmand line
-       string command;
-
-       /// Process ID of child
-       pid_t pid;
-
-       /// Return value from child
-       int retval;
-       
-       ///
-       int startscript();
-       
-       ///
-       pid_t fork();
-       
-       /// Wait for child process to finish. Updates returncode from child.
-       void waitForChild();
+        *  The string "what" contains a commandline with arguments separated 
+        *  by spaces.
+        */
+       Systemcalls(Starttype how, string const & what);
+
+       /** Start child process.
+        *  This is for reuse of the Systemcalls instance.
+        */
+       int startscript(Starttype how, string const & what);
 };
+
+#endif // SYSCALL_H
diff --git a/src/support/syscontr.C b/src/support/syscontr.C
deleted file mode 100644 (file)
index e15294f..0000000
+++ /dev/null
@@ -1,112 +0,0 @@
-#include <config.h>
-
-#include <cerrno>
-#include <cstdlib>
-#include <unistd.h>
-#include <sys/wait.h>
-#include "syscontr.h"
-#include "syscall.h"
-#include "debug.h"
-
-#ifdef __GNUG__
-#pragma implementation
-#endif
-
-
-using std::endl;
-
-#ifndef CXX_GLOBAL_CSTD
-using std::strerror;
-#endif
-
-//
-// Default constructor
-//
-
-SystemcallsSingletoncontroller::SystemcallsSingletoncontroller() 
-{
-       sysCalls = 0;
-}
-
-//
-// Destructor
-// 
-// destroy structs for leaving program
-// open question: should we stop childs here?
-// Asger says no: I like to have my xdvi open after closing LyX. Maybe
-// I want to print or something.
-
-SystemcallsSingletoncontroller::~SystemcallsSingletoncontroller()
-{
-       ControlledCalls *next;
-       while (sysCalls)
-       {
-               next = sysCalls->next;
-               delete sysCalls;
-              sysCalls = next;
-       }
-       
-}
-
-//
-// Add child process information into controlled list
-//
-
-void 
-SystemcallsSingletoncontroller::addCall(Systemcalls const &newcall) {
-       ControlledCalls * newCall = new ControlledCalls;
-       if (newCall == 0) // sorry, no idea
-               return;
-       newCall->next = sysCalls;
-       newCall->call = new Systemcalls(newcall);
-       sysCalls = newCall;
-}
-
-// 
-// Timer-call
-// 
-// Check list, if there is a stopped child. If yes, call-back.
-//
-
-void 
-SystemcallsSingletoncontroller::timer() {
-       lyxerr << "Tick" << endl;
-       // check each entry of our list, if it's finished
-        ControlledCalls *prev = 0;
-       for (ControlledCalls *actCall= sysCalls; actCall; actCall= actCall->next)
-       {
-               pid_t pid= actCall->call->getpid();
-               int stat_loc;
-               int waitrpid = waitpid(pid, &stat_loc, WNOHANG);
-               if (waitrpid == -1) {
-                       lyxerr << "LyX: Error waiting for child:" 
-                              << strerror(errno) << endl;
-               } else if (WIFEXITED(stat_loc) || WIFSIGNALED(stat_loc)) {
-                       if (WIFEXITED(stat_loc)) {
-                               // Ok, the return value goes into retval.
-                               actCall->call->setRetValue(WEXITSTATUS(stat_loc));
-                       } else {
-                               // Child died, so pretend it returned 1
-                               actCall->call->setRetValue(1);
-                       }
-                       // Callback and release
-                       actCall->call->callback();
-                       if (actCall == sysCalls) {
-                               sysCalls = actCall->next;
-                       } else {
-                               prev->next = actCall->next;
-                       }
-                       delete actCall;
-                       actCall = prev;
-               } else if (WIFSTOPPED(stat_loc)) {
-                       lyxerr << "LyX: Child (pid: " << pid 
-                              << ") stopped on signal "
-                              << WSTOPSIG(stat_loc) 
-                              << ". Waiting for child to finish." << endl;
-               } else {
-                       lyxerr << "LyX: Something rotten happened while "
-                               "waiting for child " << pid << endl;
-               }
-               prev = actCall;
-       }
-}
diff --git a/src/support/syscontr.h b/src/support/syscontr.h
deleted file mode 100644 (file)
index 4066d84..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// -*- C++ -*-
-
-#ifdef __GNUG__
-#pragma interface
-#endif
-
-#include "LString.h"
-
-
-class Systemcalls;
-
-///
-class SystemcallsSingletoncontroller {
-public:
-       ///
-       class Startcontroller {
-       public:
-               ///
-               Startcontroller();
-               ///
-                ~Startcontroller();
-               ///
-               static SystemcallsSingletoncontroller * getController();
-               ///
-                void reduceRefcount() { --refcount; }
-       private:
-               ///
-               static SystemcallsSingletoncontroller * contr;
-               ///
-                static int refcount;
-        };
-       ///
-       ~SystemcallsSingletoncontroller();
-       ///
-       void addCall(Systemcalls const & newcall);
-       ///
-       void timer();
-       /// private: // DEC cxx does not like that (JMarc)
-       SystemcallsSingletoncontroller();
-private:
-       ///
-       struct ControlledCalls {
-               ///
-               Systemcalls * call;
-               ///
-               ControlledCalls * next; 
-       };
-       ///
-       ControlledCalls * sysCalls;
-};
diff --git a/src/support/syssingleton.C b/src/support/syssingleton.C
deleted file mode 100644 (file)
index 3b71387..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-#include <config.h>
-
-#include "syscontr.h"
-
-
-//----------------------------------------------------------------------
-// Ensure, that only one controller exist inside process
-//----------------------------------------------------------------------
-
-// global controller variable
-SystemcallsSingletoncontroller *
-SystemcallsSingletoncontroller::Startcontroller::
-contr = 0;
-
-// reference count
-int SystemcallsSingletoncontroller::Startcontroller::
-refcount = 0;
-
-SystemcallsSingletoncontroller::Startcontroller::
-Startcontroller() {
-}
-
-SystemcallsSingletoncontroller::Startcontroller::
-~Startcontroller() {
-}
-
-// Give reference to global controller-instance
-// 
-SystemcallsSingletoncontroller *
-SystemcallsSingletoncontroller::Startcontroller::getController()
-{ 
-       if (!contr) { 
-               // Create the global controller
-                contr = new SystemcallsSingletoncontroller;
-       }
-       ++refcount;
-       return contr;
-}
index c2d022344eb29f5ea48665ab146d1c54c01a7f28..78405f16a83ce342ba7fd5d1bdf3dad700438f84 100644 (file)
@@ -17,6 +17,7 @@
 #include "support/path.h"
 #include "support/filetools.h"
 #include "support/lstrings.h"
+#include "support/syscall.h"
 
 #include <fstream>
 
@@ -29,7 +30,7 @@ int VCS::doVCCommand(string const & cmd, string const & path)
        lyxerr[Debug::LYXVC] << "doVCCommand: " << cmd << endl;
         Systemcalls one;
        Path p(path);
-       int const ret = one.startscript(Systemcalls::System, cmd);
+       int const ret = one.startscript(Systemcalls::Wait, cmd);
        return ret;
 }