mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-28 20:45:47 +00:00
aabd481ab6
include <config.h> in .C files, not .h ones; licence blurb. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@9876 a592a061-630c-0410-9148-cb99ea01b6c8
80 lines
1.8 KiB
C++
80 lines
1.8 KiB
C++
// -*- C++ -*-
|
|
/**
|
|
* \file forkedcontr.h
|
|
* 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().
|
|
*/
|
|
|
|
#ifndef FORKEDCONTR_H
|
|
#define FORKEDCONTR_H
|
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
#ifdef HAVE_SYS_TYPES_H
|
|
# include <sys/types.h>
|
|
#endif
|
|
|
|
#include <list>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
|
|
namespace lyx {
|
|
namespace support {
|
|
|
|
class ForkedProcess;
|
|
|
|
class ForkedcallsController {
|
|
public:
|
|
/// Get hold of the only controller that can exist inside the process.
|
|
static ForkedcallsController & get();
|
|
|
|
/// Add a new child process to the list of controlled processes.
|
|
void addCall(ForkedProcess const &);
|
|
|
|
/** 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 handleCompletedProcesses();
|
|
|
|
/** Kill this process prematurely and remove it from the list.
|
|
* The process is killed within tolerance secs.
|
|
* See forkedcall.[Ch] for details.
|
|
*/
|
|
void kill(pid_t, int tolerance = 5);
|
|
|
|
private:
|
|
ForkedcallsController();
|
|
ForkedcallsController(ForkedcallsController const &);
|
|
~ForkedcallsController();
|
|
|
|
typedef boost::shared_ptr<ForkedProcess> ForkedProcessPtr;
|
|
typedef std::list<ForkedProcessPtr> ListType;
|
|
typedef ListType::iterator iterator;
|
|
|
|
iterator find_pid(pid_t);
|
|
|
|
/// The child processes
|
|
ListType forkedCalls;
|
|
};
|
|
|
|
|
|
#if defined(_WIN32)
|
|
// a wrapper for GetLastError() and FormatMessage().
|
|
std::string const getChildErrorMessage();
|
|
#endif
|
|
|
|
} // namespace support
|
|
} // namespace lyx
|
|
|
|
#endif // FORKEDCONTR_H
|