19#ifndef CORE_POSIX_CHILD_PROCESS_H_
20#define CORE_POSIX_CHILD_PROCESS_H_
26#include <core/signal.h>
65 std::shared_ptr<SignalTrap> trap);
78 virtual bool add(
const ChildProcess& child) = 0;
85 virtual bool has(
const ChildProcess& child)
const = 0;
90 virtual const core::Signal<ChildProcess>&
child_died()
const = 0;
120 std::istream&
cerr();
130 std::istream&
cout();
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;
virtual bool add(const ChildProcess &child)=0
add adds the specified child to the list of observed child processes.
DeathObserver & operator=(const DeathObserver &)=delete
static std::unique_ptr< DeathObserver > create_once_with_signal_trap(std::shared_ptr< SignalTrap > trap)
Creates the unique instance of class DeathObserver.
virtual bool has(const ChildProcess &child) const =0
has checks whether the specified child is observed.
virtual ~DeathObserver()=default
virtual void on_sig_child()=0
Checks and reaps all child processes registered with the observer instance.
bool operator==(const DeathObserver &) const =delete
DeathObserver(const DeathObserver &)=delete
virtual const core::Signal< ChildProcess > & child_died() const =0
child_died is emitted whenever an observed child ceases to exist.
The Process class models a child process of this process.
static ChildProcess invalid()
Creates an invalid ChildProcess.
friend ChildProcess vfork(const std::function< posix::exit::Status()> &, const StandardStream &)
fork vforks a new process and executes the provided main function in the newly forked process.
wait::Result wait_for(const wait::Flags &flags)
Wait for the child process to change state.
friend ChildProcess fork(const std::function< posix::exit::Status()> &, const StandardStream &)
fork forks a new process and executes the provided main function in the newly forked process.
std::ostream & cin()
Access this process's stdin.
std::istream & cerr()
Access this process's stderr.
std::istream & cout()
Access this process's stdout.
Process(pid_t pid)
Creates a process instance wrapping an existing process.
Status
The Status enum wrap's the posix exit status.
Flags
Flags enumerates different behavior when waiting for a child process to change state.
StandardStream
The StandardStream enum wraps the POSIX standard streams.
The Result struct encapsulates the result of waiting for a process state change.
#define CORE_POSIX_DLL_PUBLIC
#define CORE_POSIX_DLL_LOCAL