- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Classes | Static Public Member Functions | List of all members
G::Process Class Reference

A static interface for doing things with processes. More...

`#include <gprocess.h>`

Inheritance diagram for G::Process:

## Classes
class | Id
| Process-id class. More...
class | IdImp
| A private implementation class used by G::Process. More...
class | NoThrow
| An overload discriminator for Process. More...
class | Umask
| Used to temporarily modify the process umask. More...

## Static Public Member Functions
static void | closeFiles (bool keep_stderr=false)
| Closes all open file descriptors. More...
static void | closeFiles (int fd)
| Closes all open file descriptors except the given one. More...
static void | closeStderr ()
| Closes stderr. More...
static void | cd (const Path &dir)
| Changes directory. More...
static bool | cd (const Path &dir, NoThrow)
| Changes directory. Returns false on error. More...
static int | errno_ ()
| Returns the process's current 'errno' value. More...
static int | errno_ (int)
| Sets the process's 'errno' value. More...
static std::string | strerror (int errno_)
| Translates an 'errno' value into a meaningful diagnostic string. More...
static void | revokeExtraGroups ()
| Revokes secondary group memberships if really root or if suid. More...
static Identity | beOrdinary (Identity nobody, bool change_group=true)
| Revokes special privileges (root or suid). More...
static Identity | beSpecial (Identity special, bool change_group=true)
| Re-acquires special privileges (either root or suid). More...
static Identity | beOrdinary (SignalSafe, Identity nobody, bool change_group=true)
| A signal-safe overload. More...
static Identity | beSpecial (SignalSafe, Identity special, bool change_group=true)
| A signal-safe overload. More...
static void | beNobody (Identity)
| If currently running with a real identity of root then the real identity is set to the nobody identity and the effective identity is set to root. More...

## Detailed Description

A static interface for doing things with processes.

See also
  G::Identity

Definition at line 44 of file gprocess.h.

## Member Function Documentation

void G::Process::beNobody | ( | Identity | nobody | ) |
| static

If currently running with a real identity of root then the real identity is set to the nobody identity and the effective identity is set to root.

Must only be used before exec()ing a new executable image, in which case the old effective ids are lost anywas by the exec().

Definition at line 192 of file gprocess_unix.cpp.

References G::Identity::real(), and G::Identity::root().

Referenced by G::NewProcess::spawn().

G::Identity G::Process::beOrdinary | ( | Identity | nobody,
|  | bool | change_group = `true`
| ) |  |
| static

Revokes special privileges (root or suid).

If really root (as opposed to suid root) then the effective id is changed to that passed in.

If suid (including suid-root), then the effective id is changed to the real id, and the parameter is ignored.

Returns the old identity, which can be passed to beSpecial().

See also class G::Root.

Definition at line 154 of file gprocess_unix.cpp.

References G::Identity::effective(), G::Identity::real(), and G::Identity::root().

Referenced by G::Root::init(), G::Root::stop(), and G::Root::~Root().

G::Identity G::Process::beOrdinary | ( | SignalSafe | safe,
|  | Identity | nobody,
|  | bool | change_group = `true`
| ) |  |
| static

A signal-safe overload.

Definition at line 173 of file gprocess_unix.cpp.

References G::Identity::effective(), G::Identity::real(), and G::Identity::root().

G::Identity G::Process::beSpecial | ( | Identity | special,
|  | bool | change_group = `true`
| ) |  |
| static

Re-acquires special privileges (either root or suid).

The parameter must have come from a previous call to beOrdinary().

Returns the old identity (which is normally ignored).

See also class G::Root.

Definition at line 134 of file gprocess_unix.cpp.

References G::Identity::effective(), G::Identity::isRoot(), and G::Identity::real().

Referenced by G::Root::Root(), and G::Root::start().

G::Identity G::Process::beSpecial | ( | SignalSafe | safe,
|  | Identity | special,
|  | bool | change_group = `true`
| ) |  |
| static

A signal-safe overload.

Definition at line 144 of file gprocess_unix.cpp.

References G::Identity::effective(), G::Identity::isRoot(), and G::Identity::real().

void G::Process::cd | ( | const Path & | dir | ) |
| static

Changes directory.

Definition at line 52 of file gprocess_unix.cpp.

References G::Path::str().

Referenced by G::Daemon::detach().

bool G::Process::cd | ( | const Path & | dir,
|  | NoThrow |
| ) |  |
| static

Changes directory. Returns false on error.

Definition at line 58 of file gprocess_unix.cpp.

References G::Path::str().

void G::Process::closeFiles | ( | bool | keep_stderr = `false` | ) |
| static

Closes all open file descriptors.

Definition at line 70 of file gprocess_unix.cpp.

Referenced by G::NewProcess::spawn().

void G::Process::closeFiles | ( | int | fd | ) |
| static

Closes all open file descriptors except the given one.

Definition at line 75 of file gprocess_unix.cpp.

References G_ASSERT, and G::FileSystem::nullDevice().

void G::Process::closeStderr | ( |  | ) |
| static

Closes stderr.

Definition at line 63 of file gprocess_unix.cpp.

References G::FileSystem::nullDevice().

int G::Process::errno_ | ( |  | ) |
| static

Returns the process's current 'errno' value.

Definition at line 107 of file gprocess_unix.cpp.

Referenced by gcleanup_unix_handler_(), and G::File::link().

int G::Process::errno_ | ( | int | e | ) |
| static

Sets the process's 'errno' value.

Returns the old value. Used in signal handlers.

Definition at line 112 of file gprocess_unix.cpp.

void G::Process::revokeExtraGroups | ( |  | ) |
| static

Revokes secondary group memberships if really root or if suid.

Definition at line 125 of file gprocess_unix.cpp.

References G::Identity::effective(), and G::Identity::real().

Referenced by G::Root::init().

std::string G::Process::strerror | ( | int | errno_ | ) |
| static

Translates an 'errno' value into a meaningful diagnostic string.

Definition at line 119 of file gprocess_unix.cpp.

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

- gprocess.h
- gprocess_unix.cpp