From af1c3bc1b00bc50f93ba1102c53e468c9a5d0a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gullik=20Bj=C3=B8nnes?= Date: Thu, 1 Mar 2001 14:26:01 +0000 Subject: [PATCH] lyx-devel.diff git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@1650 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/support/ChangeLog | 7 +++++++ src/support/filetools.C | 1 - src/support/syscall.C | 19 ++++++++----------- src/support/syscall.h | 1 + 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/support/ChangeLog b/src/support/ChangeLog index fee26038b3..8edc1e5142 100644 --- a/src/support/ChangeLog +++ b/src/support/ChangeLog @@ -1,3 +1,10 @@ +2001-02-28 Baruch Even + + * filetools.C: Removed dependency on syscall.h + + * syscall.h: + * syscall.C: Minor cleanings before I start to touch this code. + 2001-02-27 Lars Gullik Bjønnes * filetools.C (CreateTmpDir): change umask to 0700. diff --git a/src/support/filetools.C b/src/support/filetools.C index 725e1557a1..b9de57da7b 100644 --- a/src/support/filetools.C +++ b/src/support/filetools.C @@ -32,7 +32,6 @@ #include "lyx_gui_misc.h" #include "FileInfo.h" #include "support/path.h" // I know it's OS/2 specific (SMiyata) -#include "support/syscall.h" #include "gettext.h" #include "lyxlib.h" diff --git a/src/support/syscall.C b/src/support/syscall.C index 5df0404cd1..46591cc82a 100644 --- a/src/support/syscall.C +++ b/src/support/syscall.C @@ -25,12 +25,7 @@ Systemcalls::Systemcalls() { Systemcalls::Systemcalls(Starttype how, string const & what, Callbackfct cback) { - start = how; - command = what; - cbk = cback; - pid = static_cast(0); - retval = 0; - startscript(); + startscript(how, what, cback); } Systemcalls::~Systemcalls() { @@ -95,7 +90,7 @@ void Systemcalls::kill(int /*tolerance*/) { if (wait_for_death) { // Here, we should add the PID to a list of // waiting processes to kill if they are not - // dead without tolerance seconds + // dead within tolerance seconds // CHECK Implement this using the timer of // the singleton systemcontroller (Asger) @@ -144,14 +139,16 @@ pid_t Systemcalls::fork() { pid_t cpid= ::fork(); if (cpid == 0) { // child + // 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; - do { + bool more = true; + while (more) { childcommand = frontStrip(childcommand); if (syscmd == 0) { syscmd = new char[childcommand.length() + 1]; @@ -169,7 +166,7 @@ pid_t Systemcalls::fork() more = !rest.empty(); if (more) rest = split(rest, childcommand, ' '); - } while (more); + } argv[index] = 0; // replace by command. Expand using PATH-environment-var. execvp(syscmd, argv); @@ -187,7 +184,7 @@ pid_t Systemcalls::fork() // Reuse of instance int Systemcalls::startscript(Starttype how, string const & what, - Callbackfct cback) + Callbackfct cback) { start = how; command = what; diff --git a/src/support/syscall.h b/src/support/syscall.h index 4aa51cece7..dd014ae112 100644 --- a/src/support/syscall.h +++ b/src/support/syscall.h @@ -86,6 +86,7 @@ public: 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;