31 #include <sys/types.h>
47 G_EXCEPTION( CannotChangeDirectory ,
"cannot cd()" ) ;
48 G_EXCEPTION( InvalidId ,
"invalid process-id string" ) ;
54 public:
explicit Id( std::istream & ) ;
55 public: Id( SignalSafe ,
const char * pid_file_path ) ;
56 public: std::string str()
const ;
57 public:
bool operator==(
const Id & )
const ;
58 private: pid_t m_pid ;
59 friend class NewProcess ;
60 friend class Process ;
64 public:
enum Mode { Readable , Tighter , Tightest , GroupOpen } ;
65 public:
explicit Umask( Mode ) ;
67 public:
static void set( Mode ) ;
68 public:
static void tighten() ;
69 private: Umask(
const Umask & ) ;
70 private:
void operator=(
const Umask & ) ;
71 private:
class UmaskImp ;
72 private: UmaskImp * m_imp ;
77 static void closeFiles(
bool keep_stderr =
false ) ;
82 static void closeFilesExcept(
int fd_1 ,
int fd_2 = -1 ) ;
87 static void closeStderr() ;
90 static void cd(
const Path & dir ) ;
93 static bool cd(
const Path & dir , NoThrow ) ;
99 static int errno_(
const SignalSafe & ,
int e_new ) ;
103 static std::string strerror(
int errno_ ) ;
107 static void revokeExtraGroups() ;
111 static Identity beOrdinary( Identity ordinary_id ,
bool change_group =
true ) ;
122 static Identity beSpecial( Identity special_id ,
bool change_group =
true ) ;
130 static Identity beOrdinary( SignalSafe , Identity ordinary_id ,
bool change_group =
true ) ;
133 static Identity beSpecial( SignalSafe , Identity special_id ,
bool change_group =
true ) ;
136 static void beOrdinaryForExec( Identity run_as_id ) ;
141 static std::string cwd(
bool no_throw =
false ) ;
145 static std::string exe() ;
157 std::ostream & operator<<( std::ostream & stream ,
const G::Process::Id &
id )
159 return stream <<
id.str() ;
163 std::istream & operator>>( std::istream & stream , G::Process::Id &
id )
165 id = G::Process::Id( stream ) ;
An empty structure that is used to indicate a signal-safe, reentrant implementation.
A convenience class which, when used as a private base, can improve readability when calling Identity...
A static interface for doing things with processes.