process-cpp
3.0.0
A simple convenience library for handling processes in C++11.
|
Go to the documentation of this file.
19 #ifndef CORE_POSIX_CHILD_PROCESS_H_
20 #define CORE_POSIX_CHILD_PROCESS_H_
26 #include <core/signal.h>
64 static std::unique_ptr<DeathObserver> create_once_with_signal_trap(
65 std::shared_ptr<SignalTrap> trap);
90 virtual const core::Signal<ChildProcess>&
child_died()
const = 0;
120 std::istream&
cerr();
130 std::istream&
cout();
139 static Pipe invalid();
142 Pipe(
const Pipe& rhs);
145 Pipe& operator=(
const Pipe& rhs);
148 void close_read_fd();
150 int write_fd()
const;
151 void close_write_fd();
164 std::shared_ptr<Private> d;
169 #endif // CORE_POSIX_CHILD_PROCESS_H_
#define CORE_POSIX_DLL_LOCAL
configure_file(process-cpp.pc.in process-cpp.pc @ONLY) install(FILES $
virtual bool has(const ChildProcess &child) const =0
has checks whether the specified child is observed.
cmake_build_type_lower if("${cmake_build_type_lower}" STREQUAL "debug") option(PROCESS_CPP_ENABLE_DOC_GENERATION_BY_DEFAULT "Generate package by default" OFF) else() option(PROCESS_CPP_ENABLE_DOC_GENERATION_BY_DEFAULT "Generate package by default" ON) endif() if(PROCESS_CPP_ENABLE_DOC_GENERATION) if($
CORE_POSIX_DLL_PUBLIC ChildProcess vfork(const std::function< posix::exit::Status()> &main, const StandardStream &flags)
fork vforks a new process and executes the provided main function in the newly forked process.
virtual bool add(const ChildProcess &child)=0
add adds the specified child to the list of observed child processes.
StandardStream
The StandardStream enum wraps the POSIX standard streams.
usr bin c fPIC version build process cpp src process cpp symbols map sort as z
add_library(process-cpp SHARED core/posix/backtrace.h core/posix/backtrace.cpp core/posix/child_process.cpp core/posix/exec.cpp core/posix/fork.cpp core/posix/process.cpp core/posix/process_group.cpp core/posix/signal.cpp core/posix/signalable.cpp core/posix/standard_stream.cpp core/posix/wait.cpp core/posix/this_process.cpp core/posix/linux/proc/process/oom_adj.cpp core/posix/linux/proc/process/oom_score.cpp core/posix/linux/proc/process/oom_score_adj.cpp core/posix/linux/proc/process/stat.cpp core/testing/cross_process_sync.cpp core/testing/fork_and_run.cpp) target_link_libraries(process-cpp $
option(PROCESS_CPP_ENABLE_DOC_GENERATION "Generate package documentation with doxygen" ON) string(TOLOWER "$
#define CORE_POSIX_DLL_PUBLIC
usr bin c fPIC version build process cpp src process cpp symbols map O1
The DeathObserver class observes child process' states and emits a signal when a monitored child has ...
Status
The Status enum wrap's the posix exit status.
The Result struct encapsulates the result of waiting for a process state change.
CORE_POSIX_DLL_PUBLIC std::ostream & cerr() noexcept(true)
Access this process's stderr.
CORE_POSIX_DLL_PUBLIC ChildProcess exec(const std::string &fn, const std::vector< std::string > &argv, const std::map< std::string, std::string > &env, const StandardStream &flags)
exec execve's the executable with the provided arguments and environment.
set(IS_ALL ALL) endif() find_package(Doxygen) if(DOXYGEN_FOUND) configure_file($
usr bin c fPIC version script
CORE_POSIX_DLL_PUBLIC ChildProcess fork(const std::function< posix::exit::Status()> &main, const StandardStream &flags)
fork forks a new process and executes the provided main function in the newly forked process.
The Process class models a child process of this process.
usr bin c fPIC D_FORTIFY_SOURCE
virtual ~DeathObserver()=default
CORE_POSIX_DLL_PUBLIC std::istream & cin() noexcept(true)
Access this process's stdin.
usr bin c fPIC version build process cpp src process cpp symbols map Wl
virtual void on_sig_child()=0
Checks and reaps all child processes registered with the observer instance.
cmake_minimum_required(VERSION 2.8) project(process-cpp) find_package(Boost COMPONENTS iostreams system REQUIRED) find_package(PkgConfig REQUIRED) find_package(Threads REQUIRED) pkg_check_modules(PROPERTIES_CPP properties-cpp) set(CMAKE_MODULE_PATH $
CORE_POSIX_DLL_PUBLIC std::ostream & cout() noexcept(true)
Access this process's stdout.
usr bin c fPIC version build process cpp src process cpp symbols map sort common
usr bin c fPIC version build process cpp src process cpp symbols map sort as needed
virtual const core::Signal< ChildProcess > & child_died() const =0
child_died is emitted whenever an observed child ceases to exist.
usr bin c fPIC version build process cpp src process cpp symbols map sort as now no undefined shared soname
DeathObserver & operator=(const DeathObserver &)=delete
usr bin c fPIC version build process cpp src process cpp symbols map sort as relro
bool operator==(const DeathObserver &) const =delete
DeathObserver(const DeathObserver &)=delete
The Process class models a process and possible operations on it.
CORE_POSIX_DLL_PUBLIC ForkAndRunResult fork_and_run(const std::function< core::posix::exit::Status()> &service, const std::function< core::posix::exit::Status()> &client)
Forks two processes for both the service and the client.
Flags
Flags enumerates different behavior when waiting for a child process to change state.