Merge branch 'develop' of https://github.com/pocoproject/poco into develop

This commit is contained in:
Aleksandar Fabijanic 2013-06-03 23:46:34 -05:00
commit b2d72dcacb
15 changed files with 73 additions and 34 deletions

View File

@ -121,6 +121,11 @@ public:
void start()
/// Starts the activity by acquiring a
/// thread for it from the default thread pool.
{
start(ThreadPool::defaultPool());
}
void start(ThreadPool& pool)
{
FastMutex::ScopedLock lock(_mutex);
@ -131,7 +136,7 @@ public:
_running = true;
try
{
ThreadPool::defaultPool().start(*this);
pool.start(*this);
}
catch (...)
{

View File

@ -237,7 +237,7 @@ public:
/// Waits for the process specified by handle to terminate
/// and returns the exit code of the process.
static void kill(const ProcessHandle& handle);
static void kill(ProcessHandle& handle);
/// Kills the process specified by handle.
///
/// This is preferable on Windows where process IDs

View File

@ -84,7 +84,7 @@ public:
Pipe* outPipe,
Pipe* errPipe,
const EnvImpl& env);
static void killImpl(const ProcessHandleImpl& handle);
static void killImpl(ProcessHandleImpl& handle);
static void killImpl(PIDImpl pid);
static void requestTerminationImpl(PIDImpl pid);

View File

@ -85,7 +85,7 @@ public:
Pipe* errPipe,
const EnvImpl& env);
static int waitImpl(PIDImpl pid);
static void killImpl(const ProcessHandleImpl& handle);
static void killImpl(ProcessHandleImpl& handle);
static void killImpl(PIDImpl pid);
static void requestTerminationImpl(PIDImpl pid);
};

View File

@ -86,7 +86,7 @@ public:
Pipe* outPipe,
Pipe* errPipe,
const EnvImpl& env);
static void killImpl(const ProcessHandleImpl& handle);
static void killImpl(ProcessHandleImpl& handle);
static void killImpl(PIDImpl pid);
static void requestTerminationImpl(PIDImpl pid);
};

View File

@ -62,7 +62,8 @@ public:
UInt32 id() const;
HANDLE process() const;
int wait() const;
void closeHandle();
private:
HANDLE _hProcess;
UInt32 _pid;
@ -89,7 +90,7 @@ public:
Pipe* outPipe,
Pipe* errPipe,
const EnvImpl& env);
static void killImpl(const ProcessHandleImpl& handle);
static void killImpl(ProcessHandleImpl& handle);
static void killImpl(PIDImpl pid);
static void requestTerminationImpl(PIDImpl pid);
static std::string terminationEventName(PIDImpl pid);

View File

@ -62,6 +62,7 @@ public:
UInt32 id() const;
HANDLE process() const;
int wait() const;
void closeHandle();
private:
HANDLE _hProcess;
@ -89,7 +90,7 @@ public:
Pipe* outPipe,
Pipe* errPipe,
const EnvImpl& env);
static void killImpl(const ProcessHandleImpl& handle);
static void killImpl(ProcessHandleImpl& handle);
static void killImpl(PIDImpl pid);
static void requestTerminationImpl(PIDImpl pid);
static std::string terminationEventName(PIDImpl pid);

View File

@ -62,7 +62,8 @@ public:
UInt32 id() const;
HANDLE process() const;
int wait() const;
void closeHandle();
private:
HANDLE _hProcess;
UInt32 _pid;
@ -89,7 +90,7 @@ public:
Pipe* outPipe,
Pipe* errPipe,
const EnvImpl& env);
static void killImpl(const ProcessHandleImpl& handle);
static void killImpl(ProcessHandleImpl& handle);
static void killImpl(PIDImpl pid);
static void requestTerminationImpl(PIDImpl pid);
static std::string terminationEventName(PIDImpl pid);

View File

@ -200,7 +200,7 @@ int Process::wait(const ProcessHandle& handle)
}
void Process::kill(const ProcessHandle& handle)
void Process::kill(ProcessHandle& handle)
{
killImpl(*handle._pImpl);
}

View File

@ -218,7 +218,7 @@ ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command,
}
void ProcessImpl::killImpl(const ProcessHandleImpl& handle)
void ProcessImpl::killImpl(ProcessHandleImpl& handle)
{
killImpl(handle.id());
}

View File

@ -137,7 +137,7 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
}
void ProcessImpl::killImpl(const ProcessHandleImpl& handle)
void ProcessImpl::killImpl(ProcessHandleImpl& handle)
{
killImpl(handle.id());
}

View File

@ -89,7 +89,7 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
}
void ProcessImpl::killImpl(const ProcessHandleImpl& handle)
void ProcessImpl::killImpl(ProcessHandleImpl& handle)
{
throw Poco::NotImplementedException("Process::kill()");
}

View File

@ -56,9 +56,17 @@ ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid):
ProcessHandleImpl::~ProcessHandleImpl()
{
CloseHandle(_hProcess);
closeHandle();
}
void ProcessHandleImpl::closeHandle()
{
if (_hProcess)
{
CloseHandle(_hProcess);
_hProcess = NULL;
}
}
UInt32 ProcessHandleImpl::id() const
{
@ -228,17 +236,19 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
}
void ProcessImpl::killImpl(const ProcessHandleImpl& handle)
void ProcessImpl::killImpl(ProcessHandleImpl& handle)
{
if (TerminateProcess(handle.process(), 0) == 0)
if (handle.process())
{
CloseHandle(handle.process());
throw SystemException("cannot kill process");
if (TerminateProcess(handle.process(), 0) == 0)
{
handle.closeHandle();
throw SystemException("cannot kill process");
}
handle.closeHandle();
}
CloseHandle(handle.process());
}
void ProcessImpl::killImpl(PIDImpl pid)
{
HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);

View File

@ -57,9 +57,17 @@ ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid):
ProcessHandleImpl::~ProcessHandleImpl()
{
CloseHandle(_hProcess);
closeHandle();
}
void ProcessHandleImpl::closeHandle()
{
if (_hProcess)
{
CloseHandle(_hProcess);
_hProcess = NULL;
}
}
UInt32 ProcessHandleImpl::id() const
{
@ -234,17 +242,19 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
}
void ProcessImpl::killImpl(const ProcessHandleImpl& handle)
void ProcessImpl::killImpl(ProcessHandleImpl& handle)
{
if (TerminateProcess(handle.process(), 0) == 0)
if (handle.process())
{
CloseHandle(handle.process());
throw SystemException("cannot kill process");
if (TerminateProcess(handle.process(), 0) == 0)
{
handle.closeHandle();
throw SystemException("cannot kill process");
}
handle.closeHandle();
}
CloseHandle(handle.process());
}
void ProcessImpl::killImpl(PIDImpl pid)
{
HANDLE hProc = OpenProcess(PROCESS_TERMINATE, FALSE, pid);

View File

@ -57,9 +57,17 @@ ProcessHandleImpl::ProcessHandleImpl(HANDLE hProcess, UInt32 pid):
ProcessHandleImpl::~ProcessHandleImpl()
{
CloseHandle(_hProcess);
closeHandle();
}
void ProcessHandleImpl::closeHandle()
{
if (_hProcess)
{
CloseHandle(_hProcess);
_hProcess = NULL;
}
}
UInt32 ProcessHandleImpl::id() const
{
@ -158,14 +166,17 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
}
void ProcessImpl::killImpl(const ProcessHandleImpl& handle)
void ProcessImpl::killImpl(ProcessHandleImpl& handle)
{
if (TerminateProcess(handle.process(), 0) == 0)
if (handle.process())
{
CloseHandle(handle.process());
throw SystemException("cannot kill process");
if (TerminateProcess(handle.process(), 0) == 0)
{
handle.closeHandle();
throw SystemException("cannot kill process");
}
handle.closeHandle();
}
CloseHandle(handle.process());
}