X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Fsupport%2Fforkedcontr.h;h=7f55c798d06e15bfdcdc77b045a995e5c286c5fd;hb=c8429d4bbc2e9291a6b5742233aecb089a3eece1;hp=96db3f9655a50c00d99e6720b1c635528de401fa;hpb=3b041cc66d27f62a46f0da588508a591374a41e7;p=lyx.git diff --git a/src/support/forkedcontr.h b/src/support/forkedcontr.h index 96db3f9655..7f55c798d0 100644 --- a/src/support/forkedcontr.h +++ b/src/support/forkedcontr.h @@ -1,12 +1,14 @@ // -*- C++ -*- /** * \file forkedcontr.h - * Copyright 2001 The LyX Team - * Read COPYING + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * * \author Asger Alstrup Nielsen * \author Angus Leeming * + * Full author contact details are available in file CREDITS. + * * A class for the control of child processes launched using * fork() and execvp(). */ @@ -14,39 +16,35 @@ #ifndef FORKEDCONTR_H #define FORKEDCONTR_H +#include + +#ifdef HAVE_SYS_TYPES_H +# include +#endif + #include +#include #include -#include "LString.h" -#include -#include // needed for pid_t -#ifdef __GNUG__ -#pragma interface -#endif -class Forkedcall; -class Timeout; +namespace lyx { +namespace support { + +class ForkedProcess; -class ForkedcallsController : public SigC::Object { +class ForkedcallsController { public: /// Get hold of the only controller that can exist inside the process. - static ForkedcallsController & get(); + static ForkedcallsController & get(); /// Add a new child process to the list of controlled processes. - void addCall(Forkedcall const & newcall); + void addCall(ForkedProcess const &); - /** This method is connected to the timer. Every XX ms it is called - * so that we can check on the status of the children. Those that - * are found to have finished are removed from the list and their - * callback function is passed the final return state. + /** Those child processes that are found to have finished are removed + * from the list and their callback function is passed the final + * return state. */ - void timer(); - - /// Return a vector of the pids of all the controlled processes. - std::vector const getPIDs() const; - - /// Get the command string of the process. - string const getCommand(pid_t) const; + void handleCompletedProcesses(); /** Kill this process prematurely and remove it from the list. * The process is killed within tolerance secs. @@ -54,26 +52,28 @@ public: */ void kill(pid_t, int tolerance = 5); - /// Signal emitted when the list of current child processes changes. - SigC::Signal0 childrenChanged; - private: - /// Can't create multiple instances of ForkedcallsController. ForkedcallsController(); - /// ForkedcallsController(ForkedcallsController const &); - /// ~ForkedcallsController(); + typedef boost::shared_ptr ForkedProcessPtr; + typedef std::list ListType; + typedef ListType::iterator iterator; + + iterator find_pid(pid_t); + /// The child processes - typedef std::list ListType; - /// ListType forkedCalls; - - /** The timer. Enables us to check the status of the children - * every XX ms and to invoke a callback on completion. - */ - Timeout * timeout_; }; + +#if defined(_WIN32) +// a wrapper for GetLastError() and FormatMessage(). +std::string const getChildErrorMessage(); +#endif + +} // namespace support +} // namespace lyx + #endif // FORKEDCONTR_H