mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
70bb3a40de
* feat(Foundation): PIDFile and ProcessRunner #4064 * feat(Thread): optional signal blocking on POSIX #2978 * fix(ProcessRunner):remove logger, code enhancement #4225 * feat(Foundation): add PIDFile and ProcessRunner Tests #4064 * fix(Foundation): failing ProcessRunner Test #4064 * fix(PIDFile): remove append argument #4064 * remove Windows TODO from ProcessRunner #4064 * feat(ProcessRunnerTest): add line to checkTimeout #4064 * fix(ProcessRunner): add done flag to run() #4064 * fix(ProcessRunnerTest): add missing pidFile argument #4064 * chore(ProcessRunner): remove comments #4064 * fix(ProcessRunner): add runCount flag #4064 * fix(test): SharedLibrary and Class tests paths * fix(ProcessRunner): thread sanitizer reported data races #4064 * fix(build): pass env var to testrunner #4064 * chore(PIDFile): remove ; in comments #4064 * feat(ProcessRunner): add Win argument format #4064 * fix(Tests): add ProcessRunnerTest to vcxproj #4064 * fix(Tests): change path to TestApp #4064 * feat(Tests): windows processrunner tests #4064 * fix(Tests): duplicate ProcessRunnerTest in TestSuite vcxproj #4064 * fix(CodeQL): sw declaration hides variable #4064 * fix test binaries path for cmake * fix(Build): missing include/PIDFile.h buildWin #4064 * fix(Build): add PocoFoundation depend in buildWin #4064 * feat(ProcessRunner): test process launching multiple threads #2976 --------- Co-authored-by: Pavle <pavle@debian-gnu-linux-11.localdomain> Co-authored-by: Alex Fabijanic <alex@pocoproject.org>
91 lines
1.8 KiB
C++
91 lines
1.8 KiB
C++
//
|
|
// Process_UNIX.h
|
|
//
|
|
// Library: Foundation
|
|
// Package: Processes
|
|
// Module: Process
|
|
//
|
|
// Definition of the ProcessImpl class for Unix.
|
|
//
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#ifndef Foundation_Process_UNIX_INCLUDED
|
|
#define Foundation_Process_UNIX_INCLUDED
|
|
|
|
|
|
#include "Poco/Foundation.h"
|
|
#include "Poco/RefCountedObject.h"
|
|
#include <unistd.h>
|
|
#include <vector>
|
|
#include <map>
|
|
#include <atomic>
|
|
|
|
|
|
namespace Poco {
|
|
|
|
|
|
class Pipe;
|
|
|
|
|
|
class Foundation_API ProcessHandleImpl: public RefCountedObject
|
|
{
|
|
public:
|
|
ProcessHandleImpl(pid_t pid);
|
|
~ProcessHandleImpl();
|
|
|
|
pid_t id() const;
|
|
int wait() const;
|
|
int tryWait() const;
|
|
|
|
private:
|
|
std::atomic<pid_t> _pid;
|
|
};
|
|
|
|
|
|
class Foundation_API ProcessImpl
|
|
{
|
|
public:
|
|
typedef pid_t PIDImpl;
|
|
typedef std::vector<std::string> ArgsImpl;
|
|
typedef std::map<std::string, std::string> EnvImpl;
|
|
|
|
static PIDImpl idImpl();
|
|
static void timesImpl(long& userTime, long& kernelTime);
|
|
static ProcessHandleImpl* launchImpl(
|
|
const std::string& command,
|
|
const ArgsImpl& args,
|
|
const std::string& initialDirectory,
|
|
Pipe* inPipe,
|
|
Pipe* outPipe,
|
|
Pipe* errPipe,
|
|
const EnvImpl& env,
|
|
int options = 0);
|
|
static void killImpl(ProcessHandleImpl& handle);
|
|
static void killImpl(PIDImpl pid);
|
|
static bool isRunningImpl(const ProcessHandleImpl& handle);
|
|
static bool isRunningImpl(PIDImpl pid);
|
|
static void requestTerminationImpl(PIDImpl pid);
|
|
|
|
private:
|
|
static ProcessHandleImpl* launchByForkExecImpl(
|
|
const std::string& command,
|
|
const ArgsImpl& args,
|
|
const std::string& initialDirectory,
|
|
Pipe* inPipe,
|
|
Pipe* outPipe,
|
|
Pipe* errPipe,
|
|
const EnvImpl& env,
|
|
int options = 0);
|
|
};
|
|
|
|
|
|
} // namespace Poco
|
|
|
|
|
|
#endif // Foundation_Process_UNIX_INCLUDED
|