G::NewProcess Class Reference

A static interface for creating new processes. More...

#include <gnewprocess.h>

List of all members.

Public Types

enum  Who { Parent, Child }

Static Public Member Functions

static Who fork ()
 Forks a child process.
static Who fork (Process::Id &child)
 Forks a child process.
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.
static ChildProcess spawn (const Path &exe, const Strings &args)
 A simple overload to spawn a child process asynchronously.

Friends

class ChildProcess

Classes

class  ChildProcess
 Represents the state of a child process. More...
class  ChildProcessImp
 A private implementation class used by G::NewProcess. More...


Detailed Description

A static interface for creating new processes.

See also:
G::Daemon, G::NewProcess

Definition at line 42 of file gnewprocess.h.


Member Enumeration Documentation

Enumerator:
Parent 
Child 

Definition at line 53 of file gnewprocess.h.


Member Function Documentation

G::NewProcess::Who G::NewProcess::fork (  )  [static]

Forks a child process.

Definition at line 133 of file gnewprocess_unix_exec_enabled.cpp.

Referenced by G::Daemon::detach(), fork(), and spawn().

G::NewProcess::Who G::NewProcess::fork ( Process::Id child  )  [static]

Forks a child process.

Returns the child pid by reference to the parent.

Definition at line 139 of file gnewprocess_unix_exec_enabled.cpp.

References Child, fork(), G::Process::Id::m_pid, and Parent.

int G::NewProcess::spawn ( Identity  nobody,
const Path exe,
const Strings args,
std::string *  pipe_result_p = NULL,
int  error_return = 127,
std::string(*)(int)  error_decode_fn = 0 
) [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 231 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(), s, and G::Path::str().

G::NewProcess::ChildProcess G::NewProcess::spawn ( const Path exe,
const Strings args 
) [static]


Friends And Related Function Documentation

friend class ChildProcess [friend]

Definition at line 96 of file gnewprocess.h.

Referenced by spawn().


The documentation for this class was generated from the following files:

Generated on Fri Apr 18 15:56:13 2008 for E-MailRelay by  doxygen 1.5.5