A static interface for creating new processes. More...
#include <gnewprocess.h>
Classes | |
class | ChildProcess |
Represents the state of a child process. More... | |
class | ChildProcessImp |
A private implementation class used by G::NewProcess. More... | |
Public Types | |
enum | Who { Parent, Child } |
Static Public Member Functions | |
static Who | fork () |
Forks a child process. More... | |
static Who | fork (Process::Id &child) |
Forks a child process. More... | |
static int | spawn (Identity nobody, const Path &exe, const Strings &args, std::string *pipe_result_p=NULL, int error_return=127, std::string(*error_decode_fn)(int)=0) |
Runs a command in an unprivileged child process. More... | |
static ChildProcess | spawn (const Path &exe, const Strings &args) |
A simple overload to spawn a child process asynchronously. More... | |
Friends | |
class | ChildProcess |
A static interface for creating new processes.
Definition at line 42 of file gnewprocess.h.
enum G::NewProcess::Who |
Enumerator | |
---|---|
Parent | |
Child |
Definition at line 53 of file gnewprocess.h.
|
static |
Forks a child process.
Definition at line 134 of file gnewprocess_unix_exec_enabled.cpp.
Referenced by G::Daemon::detach(), fork(), and spawn().
|
static |
Forks a child process.
Returns the child pid by reference to the parent.
Definition at line 140 of file gnewprocess_unix_exec_enabled.cpp.
|
static |
Runs a command in an unprivileged child process.
Returns the child process's exit code, or 'error_return' on error.
The 'nobody' identity should have come from beOrdinary().
If the 'pipe_result_p' pointer is supplied then the child process is given a pipe as its stdout and this is used to read the first bit of whatever it writes.
If the function pointer is supplied then it is used to generate a string that is written into the pipe if the exec() fails in the fork()ed child process.
Definition at line 232 of file gnewprocess_unix_exec_enabled.cpp.
References G::Process::beNobody(), Child, G::Process::closeFiles(), G::Pipe::dup(), G::Identity::effective(), G::Pipe::fd(), fork(), G_ASSERT, G::Pipe::inChild(), G::Pipe::inParent(), G::Path::isRelative(), G::Identity::isRoot(), G::Pipe::read(), and G::Path::str().
|
static |
A simple overload to spawn a child process asynchronously.
Does no special security checks.
Definition at line 207 of file gnewprocess_unix_exec_enabled.cpp.
References Child, ChildProcess, G::Process::closeFiles(), G::Pipe::dup(), G::Pipe::fd(), fork(), G::Pipe::inChild(), G::Pipe::inParent(), G::NewProcess::ChildProcessImp::m_id, and G::NewProcess::ChildProcessImp::m_pipe.
|
friend |
Definition at line 96 of file gnewprocess.h.
Referenced by spawn().