A static interface for doing things with processes. More...
#include <gprocess.h>
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... | |
A static interface for doing things with processes.
Definition at line 44 of file gprocess.h.
|
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().
|
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().
|
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().
|
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().
|
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().
|
static |
Changes directory.
Definition at line 52 of file gprocess_unix.cpp.
References G::Path::str().
Referenced by G::Daemon::detach().
Changes directory. Returns false on error.
Definition at line 58 of file gprocess_unix.cpp.
References G::Path::str().
|
static |
Closes all open file descriptors.
Definition at line 70 of file gprocess_unix.cpp.
Referenced by G::NewProcess::spawn().
|
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().
|
static |
Closes stderr.
Definition at line 63 of file gprocess_unix.cpp.
References G::FileSystem::nullDevice().
|
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().
|
static |
Sets the process's 'errno' value.
Returns the old value. Used in signal handlers.
Definition at line 112 of file gprocess_unix.cpp.
|
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().
|
static |
Translates an 'errno' value into a meaningful diagnostic string.
Definition at line 119 of file gprocess_unix.cpp.