Apache Mesos
Namespaces | Classes | Functions | Variables
os Namespace Reference

Namespaces

 internal
 
 libraries
 
 raw
 
 Shell
 
 signal_safe
 
 signals
 
 stat
 
 windows
 

Classes

struct  Exec
 
struct  Fork
 
struct  Load
 
struct  Memory
 
struct  Permissions
 
struct  Process
 
class  ProcessTree
 
class  Stack
 
struct  sysctl
 
struct  UTSInfo
 
struct  Wait
 
class  WindowsFD
 

Functions

Try< bool > access (const std::string &path, int how)
 
Option< int > spawn (const std::string &file, const std::vector< std::string > &arguments)
 
int execvp (const char *file, char *const argv[])
 
int execvpe (const char *file, char **argv, char **envp)
 
Try< std::list< std::string > > find (const std::string &directory, const std::string &pattern)
 
Result< Processprocess (pid_t pid)
 
Try< std::set< pid_t > > pids ()
 
Try< Memorymemory ()
 
pid_t clone (const lambda::function< int()> &func, int flags)
 
Try< Permissionspermissions (const std::string &path)
 
Try< std::string > bootId ()
 
Try< Nothingchdir (const std::string &directory)
 
Try< Nothingchown (uid_t uid, gid_t gid, const std::string &path, bool recursive)
 
Try< Nothingchown (const std::string &user, const std::string &path, bool recursive=true)
 
Try< Nothingchroot (const std::string &directory)
 
Try< Nothingclose (int fd)
 
Try< Nothingcopyfile (const std::string &source, const std::string &destination)
 
Try< int > dup (int fd)
 
std::map< std::string, std::string > environment ()
 
bool exists (const std::string &path)
 
bool exists (pid_t pid)
 
Try< Nothingcloexec (int fd)
 
Try< NothingunsetCloexec (int fd)
 
Try< bool > isCloexec (int fd)
 
Try< Nothingnonblock (int fd)
 
Try< bool > isNonblock (int fd)
 
Try< Nothingfsync (int fd)
 
Try< Nothingfsync (const std::string &path)
 
Try< Nothingftruncate (int fd, off_t length)
 
std::string getcwd ()
 
Option< std::string > getenv (const std::string &key)
 
int kill (pid_t pid, int sig)
 
std::set< pid_tchildren (pid_t, const std::list< Process > &, bool)
 
Option< Processprocess (pid_t, const std::list< Process > &)
 
Try< std::list< Process > > processes ()
 
Try< std::list< ProcessTree > > pstrees (const std::set< pid_t > &, const std::list< Process > &)
 
Try< std::list< ProcessTree > > killtree (pid_t pid, int signal, bool groups=false, bool sessions=false)
 
Try< std::list< std::string > > ls (const std::string &directory)
 
Try< off_t > lseek (int_fd fd, off_t offset, int whence)
 
Try< std::vector< int_fd > > lsof ()
 
Try< Nothingmkdir (const std::string &directory, bool recursive=true, bool sync=false)
 
Try< std::string > mkdtemp (const std::string &path=path::join(os::temp(),"XXXXXX"))
 
Try< std::string > mktemp (const std::string &path=path::join(os::temp(),"XXXXXX"))
 
Try< int_fdopen (const std::string &path, int oflag, mode_t mode=0)
 
size_t pagesize ()
 
Try< std::array< int, 2 > > pipe ()
 
Result< std::string > realpath (const std::string &path)
 
Try< Nothingrename (const std::string &from, const std::string &to, bool sync=false)
 
Try< Nothingrm (const std::string &path)
 
Try< Nothingrmdir (const std::string &directory, bool recursive=true, bool removeRoot=true, bool continueOnError=false)
 
Try< ssize_t, SocketErrorsendfile (int s, int fd, off_t offset, size_t length)
 
template<typename... T>
Try< std::string > shell (const std::string &fmt, const T &...t)
 
Option< int > system (const std::string &command)
 
Result< uid_tgetuid (const Option< std::string > &user=None())
 
Try< Nothingsetuid (uid_t uid)
 
Result< gid_tgetgid (const Option< std::string > &user=None())
 
Try< Nothingsetgid (gid_t gid)
 
Try< std::vector< gid_t > > getgrouplist (const std::string &user)
 
Try< Nothingsetgroups (const std::vector< gid_t > &gids, const Option< uid_t > &uid=None())
 
Result< std::string > user (Option< uid_t > uid=None())
 
Try< Nothingsu (const std::string &user)
 
std::string temp ()
 
Option< std::string > which (const std::string &command, const Option< std::string > &_path=None())
 
Try< Nothingsetxattr (const std::string &path, const std::string &name, const std::string &value, int flags)
 
Try< std::string > getxattr (const std::string &path, const std::string &name)
 
Try< Nothingremovexattr (const std::string &path, const std::string &name)
 
std::ostream & operator<< (std::ostream &stream, const ProcessTree &tree)
 
Try< ProcessTreepstree (pid_t pid, const std::list< Process > &processes)
 
Try< ProcessTreepstree (Option< pid_t > pid=None())
 
Result< std::string > read (int_fd fd, size_t size)
 
Try< std::string > read (const std::string &path)
 
std::string strerror (int errno_)
 A thread-safe version of strerror. More...
 
template<typename T >
 sysctl::Table::operator Try< std::vector< T >> ()
 
Try< Nothingtouch (const std::string &path)
 
Try< Nothingutime (const std::string &path)
 
Try< Nothingclose (const int_fd &fd)
 
Try< int_fddup (const int_fd &fd)
 
Option< int > spawn (const std::string &command, const std::vector< std::string > &arguments, const Option< std::map< std::string, std::string >> &environment=None())
 
int execvp (const std::string &file, const std::vector< std::string > &argv)
 
int execvpe (const std::string &file, const std::vector< std::string > &argv, const std::map< std::string, std::string > &envp)
 
Try< Nothingcloexec (const int_fd &fd)
 
Try< NothingunsetCloexec (const int_fd &fd)
 
Try< bool > isCloexec (const int_fd &fd)
 
Try< Nothingnonblock (const int_fd &fd)
 
Try< bool > isNonblock (const int_fd &fd)
 
std::ostream & operator<< (std::ostream &stream, const WindowsFD::Type &fd)
 
std::ostream & operator<< (std::ostream &stream, const WindowsFD &fd)
 
bool operator< (int left, const WindowsFD &right)
 
bool operator< (const WindowsFD &left, int right)
 
bool operator> (int left, const WindowsFD &right)
 
bool operator> (const WindowsFD &left, int right)
 
bool operator<= (int left, const WindowsFD &right)
 
bool operator<= (const WindowsFD &left, int right)
 
bool operator>= (int left, const WindowsFD &right)
 
bool operator>= (const WindowsFD &left, int right)
 
bool operator== (int left, const WindowsFD &right)
 
bool operator== (const WindowsFD &left, int right)
 
bool operator!= (int left, const WindowsFD &right)
 
bool operator!= (const WindowsFD &left, int right)
 
bool operator== (const WindowsFD &left, const WindowsFD &right)
 
Try< Nothingfsync (const int_fd &fd)
 
Try< Nothingftruncate (const int_fd &fd, off_t length)
 
Try< std::wstring > name_job (pid_t pid)
 
Try< SharedHandleopen_job (const DWORD desired_access, const BOOL inherit_handles, const std::wstring &name)
 
Try< SharedHandleopen_job (const DWORD desired_access, const BOOL inherit_handles, const pid_t pid)
 
Try< SharedHandlecreate_job (const std::wstring &name)
 
Try< JOBOBJECT_BASIC_ACCOUNTING_INFORMATION > get_job_info (pid_t pid)
 
template<size_t max_pids>
Result< std::set< Process > > _get_job_processes (const SharedHandle &job_handle)
 
Try< std::set< Process > > get_job_processes (pid_t pid)
 
Try< Bytesget_job_mem (pid_t pid)
 
Try< Nothingset_job_kill_on_close_limit (pid_t pid)
 
Try< Nothingset_job_cpu_limit (pid_t pid, double cpus)
 
Try< Nothingset_job_mem_limit (pid_t pid, Bytes limit)
 
Try< Nothingassign_job (SharedHandle job_handle, pid_t pid)
 
Try< Nothingkill_job (SharedHandle job_handle)
 
Try< std::array< int_fd, 2 > > pipe (bool read_overlapped=true, bool write_overlapped=true)
 
Result< size_t > read_async (const int_fd &fd, void *data, size_t size, OVERLAPPED *overlapped)
 
ssize_t read (const int_fd &fd, void *data, size_t size)
 
Result< size_t > sendfile_async (const int_fd &s, const int_fd &fd, size_t length, OVERLAPPED *overlapped)
 
Try< ssize_t, SocketErrorsendfile (const int_fd &s, const int_fd &fd, off_t offset, size_t length)
 
Result< size_t > write_async (const int_fd &fd, const void *data, size_t size, OVERLAPPED *overlapped)
 
ssize_t write (const int_fd &fd, const void *data, size_t size)
 
Try< Nothingwrite (int_fd fd, const std::string &message)
 Performs a series of asynchronous writes, until all of data has been written. More...
 
Try< Nothingwrite (const std::string &path, const std::string &message, bool sync=false)
 
Try< Nothingwrite (const char *path, const std::string &message, bool sync=false)
 
Try< std::string > sysname ()
 
Try< std::set< pid_t > > children (pid_t pid, bool recursive=true)
 
Result< pid_twaitpid (pid_t pid, int *status, int options)
 
void setenv (const std::string &key, const std::string &value, bool overwrite=true)
 
void unsetenv (const std::string &key)
 
void eraseenv (const std::string &key)
 
Try< Nothingchmod (const std::string &path, int mode)
 
Try< Nothingmknod (const std::string &path, mode_t mode, dev_t dev)
 
Try< Nothingsleep (const Duration &duration)
 
Try< std::list< std::string > > glob (const std::string &pattern)
 
Try< long > cpus ()
 
Try< Loadloadavg ()
 
Try< UTSInfouname ()
 
Try< std::set< pid_t > > pids (Option< pid_t > group, Option< pid_t > session)
 
Try< Nothingtar (const std::string &path, const std::string &archive)
 
Try< Versionrelease ()
 
Try< std::string > var ()
 
Try< Nothingdup2 (int oldFd, int newFd)
 
Try< std::string > ptsname (int master)
 
Try< Nothingsetctty (int fd)
 
Try< NothingsetWindowSize (int fd, unsigned short rows, unsigned short columns)
 
std::string host_default_path ()
 
Result< pid_twaitpid (long pid, int *status, int options)
 
std::string hstrerror (int err)=delete
 
tm * gmtime_r (const time_t *timep, tm *result)
 
Result< PROCESSENTRY32W > process_entry (pid_t pid)
 
int random ()
 

Variables

constexpr char WINDOWS_PATH_SEPARATOR = '\\'
 
constexpr char POSIX_PATH_SEPARATOR = '/'
 
constexpr char PATH_SEPARATOR = POSIX_PATH_SEPARATOR
 
constexpr char DEV_NULL [] = "/dev/null"
 
const int KILL_PASS = 0
 
const int KILL_FAIL = -1
 

Function Documentation

template<size_t max_pids>
Result<std::set<Process> > os::_get_job_processes ( const SharedHandle job_handle)
Try<bool> os::access ( const std::string &  path,
int  how 
)
inline
Try<Nothing> os::assign_job ( SharedHandle  job_handle,
pid_t  pid 
)
inline
Try< std::string > os::bootId ( )
inline
Try< Nothing > os::chdir ( const std::string &  directory)
inline
std::set< pid_t > os::children ( pid_t  pid,
const std::list< Process > &  processes,
bool  recursive = true 
)
inline
Try<std::set<pid_t> > os::children ( pid_t  pid,
bool  recursive = true 
)
inline
Try< Nothing > os::chmod ( const std::string &  path,
int  mode 
)
inlinedelete
Try< Nothing > os::chown ( uid_t  uid,
gid_t  gid,
const std::string &  path,
bool  recursive 
)
inlinedelete
Try<Nothing> os::chown ( const std::string &  user,
const std::string &  path,
bool  recursive = true 
)
inline
Try< Nothing > os::chroot ( const std::string &  directory)
inlinedelete
Try<Nothing> os::cloexec ( int  fd)
inline
Try<Nothing> os::cloexec ( const int_fd fd)
inline
pid_t os::clone ( const lambda::function< int()> &  func,
int  flags 
)
inline
Try<Nothing> os::close ( int  fd)
inline
Try<Nothing> os::close ( const int_fd fd)
inline
Try< Nothing > os::copyfile ( const std::string &  source,
const std::string &  destination 
)
inline
Try< long > os::cpus ( )
inline
Try<SharedHandle> os::create_job ( const std::wstring &  name)
inline
Try<int> os::dup ( int  fd)
inline
Try<int_fd> os::dup ( const int_fd fd)
inline
Try<Nothing> os::dup2 ( int  oldFd,
int  newFd 
)
inline
std::map< std::string, std::string > os::environment ( )
inline
void os::eraseenv ( const std::string &  key)
inline
int os::execvp ( const char *  file,
char *const  argv[] 
)
inline
int os::execvp ( const std::string &  file,
const std::vector< std::string > &  argv 
)
inline
int os::execvpe ( const char *  file,
char **  argv,
char **  envp 
)
inline
int os::execvpe ( const std::string &  file,
const std::vector< std::string > &  argv,
const std::map< std::string, std::string > &  envp 
)
inline
bool os::exists ( const std::string &  path)
inline
bool os::exists ( pid_t  pid)
inline
Try<std::list<std::string> > os::find ( const std::string &  directory,
const std::string &  pattern 
)
inline
Try<Nothing> os::fsync ( const int_fd fd)
inline
Try<Nothing> os::fsync ( int  fd)
inline
Try<Nothing> os::fsync ( const std::string &  path)
inline
Try<Nothing> os::ftruncate ( const int_fd fd,
off_t  length 
)
inline
Try<Nothing> os::ftruncate ( int  fd,
off_t  length 
)
inline
Try<JOBOBJECT_BASIC_ACCOUNTING_INFORMATION> os::get_job_info ( pid_t  pid)
inline
Try<Bytes> os::get_job_mem ( pid_t  pid)
inline
Try<std::set<Process> > os::get_job_processes ( pid_t  pid)
inline
std::string os::getcwd ( )
inline
Option< std::string > os::getenv ( const std::string &  key)
inline
Result< gid_t > os::getgid ( const Option< std::string > &  user = None())
inlinedelete
Try<std::vector<gid_t> > os::getgrouplist ( const std::string &  user)
inline
Result< uid_t > os::getuid ( const Option< std::string > &  user = None())
inlinedelete
Try< std::string > os::getxattr ( const std::string &  path,
const std::string &  name 
)
inlinedelete
Try< std::list< std::string > > os::glob ( const std::string &  pattern)
inlinedelete
tm* os::gmtime_r ( const time_t *  timep,
tm *  result 
)
inline
std::string os::host_default_path ( )
inline
std::string os::hstrerror ( int  err)
inlinedelete
Try<bool> os::isCloexec ( const int_fd fd)
inline
Try<bool> os::isCloexec ( int  fd)
inline
Try<bool> os::isNonblock ( const int_fd fd)
inline
Try<bool> os::isNonblock ( int  fd)
inline
int os::kill ( pid_t  pid,
int  sig 
)
inline
Try<Nothing> os::kill_job ( SharedHandle  job_handle)
inline
Try< std::list< ProcessTree > > os::killtree ( pid_t  pid,
int  signal,
bool  groups = false,
bool  sessions = false 
)
inline
Try< Load > os::loadavg ( )
inline
Try< std::list< std::string > > os::ls ( const std::string &  directory)
inline
Try< off_t > os::lseek ( int_fd  fd,
off_t  offset,
int  whence 
)
inline
Try< std::vector< int_fd > > os::lsof ( )
inlinedelete
Try< Memory > os::memory ( )
inline
Try< Nothing > os::mkdir ( const std::string &  directory,
bool  recursive = true,
bool  sync = false 
)
inline
Try< std::string > os::mkdtemp ( const std::string &  path = path::join(os::temp(), "XXXXXX"))
inline
Try< Nothing > os::mknod ( const std::string &  path,
mode_t  mode,
dev_t  dev 
)
inlinedelete
Try< std::string > os::mktemp ( const std::string &  path = path::join(os::temp(), "XXXXXX"))
inline
Try<std::wstring> os::name_job ( pid_t  pid)
inline
Try<Nothing> os::nonblock ( const int_fd fd)
inline
Try<Nothing> os::nonblock ( int  fd)
inline
Try< int_fd > os::open ( const std::string &  path,
int  oflag,
mode_t  mode = 0 
)
inline
Try<SharedHandle> os::open_job ( const DWORD  desired_access,
const BOOL  inherit_handles,
const std::wstring &  name 
)
inline
Try<SharedHandle> os::open_job ( const DWORD  desired_access,
const BOOL  inherit_handles,
const pid_t  pid 
)
inline
bool os::operator!= ( int  left,
const WindowsFD right 
)
inline
bool os::operator!= ( const WindowsFD left,
int  right 
)
inline
bool os::operator< ( int  left,
const WindowsFD right 
)
inline
bool os::operator< ( const WindowsFD left,
int  right 
)
inline
std::ostream& os::operator<< ( std::ostream &  stream,
const ProcessTree tree 
)
inline
std::ostream& os::operator<< ( std::ostream &  stream,
const WindowsFD::Type fd 
)
inline
std::ostream& os::operator<< ( std::ostream &  stream,
const WindowsFD fd 
)
inline
bool os::operator<= ( int  left,
const WindowsFD right 
)
inline
bool os::operator<= ( const WindowsFD left,
int  right 
)
inline
bool os::operator== ( int  left,
const WindowsFD right 
)
inline
bool os::operator== ( const WindowsFD left,
int  right 
)
inline
bool os::operator== ( const WindowsFD left,
const WindowsFD right 
)
inline
bool os::operator> ( int  left,
const WindowsFD right 
)
inline
bool os::operator> ( const WindowsFD left,
int  right 
)
inline
bool os::operator>= ( int  left,
const WindowsFD right 
)
inline
bool os::operator>= ( const WindowsFD left,
int  right 
)
inline
size_t os::pagesize ( )
inline
Try<Permissions> os::permissions ( const std::string &  path)
inline
Try< std::set< pid_t > > os::pids ( )
inline
Try< std::set< pid_t > > os::pids ( Option< pid_t group,
Option< pid_t session 
)
inline
Try<std::array<int, 2> > os::pipe ( )
inline
Try<std::array<int_fd, 2> > os::pipe ( bool  read_overlapped = true,
bool  write_overlapped = true 
)
inline
Result< Process > os::process ( pid_t  pid)
inline
Option< Process > os::process ( pid_t  pid,
const std::list< Process > &  processes 
)
inline
Result<PROCESSENTRY32W> os::process_entry ( pid_t  pid)
inline
Try< std::list< Process > > os::processes ( )
inline
Try<ProcessTree> os::pstree ( pid_t  pid,
const std::list< Process > &  processes 
)
inline
Try<ProcessTree> os::pstree ( Option< pid_t pid = None())
inline
Try< std::list< ProcessTree > > os::pstrees ( const std::set< pid_t > &  pids,
const std::list< Process > &  processes 
)
inline
Try<std::string> os::ptsname ( int  master)
inline
int os::random ( )
inline
Result<std::string> os::read ( int_fd  fd,
size_t  size 
)
inline
ssize_t os::read ( const int_fd fd,
void *  data,
size_t  size 
)
inline
Try<std::string> os::read ( const std::string &  path)
inline
Result<size_t> os::read_async ( const int_fd fd,
void *  data,
size_t  size,
OVERLAPPED *  overlapped 
)
inline
Result< std::string > os::realpath ( const std::string &  path)
inline
Try< Version > os::release ( )
inlinedelete
Try< std::string > os::removexattr ( const std::string &  path,
const std::string &  name 
)
inlinedelete
Try< Nothing > os::rename ( const std::string &  from,
const std::string &  to,
bool  sync = false 
)
inline
Try< Nothing > os::rm ( const std::string &  path)
inline
Try< Nothing > os::rmdir ( const std::string &  directory,
bool  recursive = true,
bool  removeRoot = true,
bool  continueOnError = false 
)
inline
Try<ssize_t, SocketError> os::sendfile ( int  s,
int  fd,
off_t  offset,
size_t  length 
)
inline
Try<ssize_t, SocketError> os::sendfile ( const int_fd s,
const int_fd fd,
off_t  offset,
size_t  length 
)
inline
Result<size_t> os::sendfile_async ( const int_fd s,
const int_fd fd,
size_t  length,
OVERLAPPED *  overlapped 
)
inline
Try<Nothing> os::set_job_cpu_limit ( pid_t  pid,
double  cpus 
)
inline
Try<Nothing> os::set_job_kill_on_close_limit ( pid_t  pid)
inline
Try<Nothing> os::set_job_mem_limit ( pid_t  pid,
Bytes  limit 
)
inline
Try<Nothing> os::setctty ( int  fd)
inline
void os::setenv ( const std::string &  key,
const std::string &  value,
bool  overwrite = true 
)
inline
Try<Nothing> os::setgid ( gid_t  gid)
inline
Try<Nothing> os::setgroups ( const std::vector< gid_t > &  gids,
const Option< uid_t > &  uid = None() 
)
inline
Try<Nothing> os::setuid ( uid_t  uid)
inline
Try<Nothing> os::setWindowSize ( int  fd,
unsigned short  rows,
unsigned short  columns 
)
inline
Try< Nothing > os::setxattr ( const std::string &  path,
const std::string &  name,
const std::string &  value,
int  flags 
)
inlinedelete
template<typename... T>
Try< std::string > os::shell ( const std::string &  fmt,
const T &...  t 
)
Try< Nothing > os::sleep ( const Duration duration)
inline
Option< int > os::spawn ( const std::string &  file,
const std::vector< std::string > &  arguments 
)
inline
Option<int> os::spawn ( const std::string &  command,
const std::vector< std::string > &  arguments,
const Option< std::map< std::string, std::string >> &  environment = None() 
)
inline
std::string os::strerror ( int  errno_)
inline

A thread-safe version of strerror.

Try< Nothing > os::su ( const std::string &  user)
inlinedelete
template<typename T >
os::sysctl::Table::operator Try< std::vector< T >> ( )
Try<std::string> os::sysname ( )
inline
Option< int > os::system ( const std::string &  command)
inline
Try<Nothing> os::tar ( const std::string &  path,
const std::string &  archive 
)
inline
std::string os::temp ( )
inline
Try<Nothing> os::touch ( const std::string &  path)
inline
Try< UTSInfo > os::uname ( )
inlinedelete
Try<Nothing> os::unsetCloexec ( const int_fd fd)
inline
Try<Nothing> os::unsetCloexec ( int  fd)
inline
void os::unsetenv ( const std::string &  key)
inline
Result< std::string > os::user ( Option< uid_t uid = None())
inline
Try< Nothing > os::utime ( const std::string &  path)
inline
Try< std::string > os::var ( )
inline
Result<pid_t> os::waitpid ( pid_t  pid,
int *  status,
int  options 
)
inline
Result<pid_t> os::waitpid ( long  pid,
int *  status,
int  options 
)
inline
Option< std::string > os::which ( const std::string &  command,
const Option< std::string > &  _path = None() 
)
inline
ssize_t os::write ( const int_fd fd,
const void *  data,
size_t  size 
)
inline
Try<Nothing> os::write ( int_fd  fd,
const std::string &  data 
)
inline

Performs a series of asynchronous writes, until all of data has been written.

Returns
Nothing or a failure if an error occurred. A failure will be returned if the file descriptor is bad, or if the file descriptor cannot be duplicated, set to close-on-exec, or made non-blocking.
Try<Nothing> os::write ( const std::string &  path,
const std::string &  message,
bool  sync = false 
)
inline
Try<Nothing> os::write ( const char *  path,
const std::string &  message,
bool  sync = false 
)
inline
Result<size_t> os::write_async ( const int_fd fd,
const void *  data,
size_t  size,
OVERLAPPED *  overlapped 
)
inline

Variable Documentation

constexpr char os::DEV_NULL[] = "/dev/null"
const int os::KILL_FAIL = -1
const int os::KILL_PASS = 0
constexpr char os::PATH_SEPARATOR = POSIX_PATH_SEPARATOR
constexpr char os::POSIX_PATH_SEPARATOR = '/'
constexpr char os::WINDOWS_PATH_SEPARATOR = '\\'