Apache Mesos
Classes | Public Member Functions | Static Public Member Functions | Friends | List of all members
process::Subprocess Class Reference

Represents a fork() exec()ed subprocess. More...

#include <subprocess.hpp>

Classes

class  ChildHook
 A ChildHook can be passed to a subprocess call. More...
 
class  IO
 Describes how the I/O is redirected for stdin/stdout/stderr. More...
 
struct  ParentHook
 A hook can be passed to a subprocess call. More...
 

Public Member Functions

pid_t pid () const
 
Option< int_fdin () const
 
Option< int_fdout () const
 
Option< int_fderr () const
 
Future< Option< int > > status () const
 Exit status of this subprocess captured as a Future (completed when the subprocess exits). More...
 

Static Public Member Functions

static IO PIPE ()
 
static IO PATH (const std::string &path)
 
static IO FD (int_fd fd, IO::FDType type=IO::DUPLICATED)
 

Friends

Try< Subprocesssubprocess (const std::string &path, std::vector< std::string > argv, const Subprocess::IO &in, const Subprocess::IO &out, const Subprocess::IO &err, const flags::FlagsBase *flags, const Option< std::map< std::string, std::string >> &environment, const Option< lambda::function< pid_t(const lambda::function< int()> &)>> &clone, const std::vector< Subprocess::ParentHook > &parent_hooks, const std::vector< Subprocess::ChildHook > &child_hooks)
 

Detailed Description

Represents a fork() exec()ed subprocess.

Access is provided to the input / output of the process, as well as the exit status. The input / output file descriptors are only closed after:

  1. The subprocess has terminated.
  2. There are no longer any references to the associated Subprocess object.

Member Function Documentation

Option<int_fd> process::Subprocess::err ( ) const
inline
Returns
File descriptor representing the parent side (i.e., write side) of this subprocess' stderr pipe or None if no pipe was requested.
static IO process::Subprocess::FD ( int_fd  fd,
IO::FDType  type = IO::DUPLICATED 
)
static
Option<int_fd> process::Subprocess::in ( ) const
inline
Returns
File descriptor representing the parent side (i.e., write side) of this subprocess' stdin pipe or None if no pipe was requested.
Option<int_fd> process::Subprocess::out ( ) const
inline
Returns
File descriptor representing the parent side (i.e., write side) of this subprocess' stdout pipe or None if no pipe was requested.
static IO process::Subprocess::PATH ( const std::string &  path)
static
pid_t process::Subprocess::pid ( ) const
inline
Returns
The operating system PID for this subprocess.
static IO process::Subprocess::PIPE ( )
static
Future<Option<int> > process::Subprocess::status ( ) const
inline

Exit status of this subprocess captured as a Future (completed when the subprocess exits).

On Posix, the exit status is propagated from an underlying call to waitpid and can be used with macros defined in wait.h, i.e., WIFEXITED(status).

On Windows, the exit status contains the exit code from an underlying call to GetExitCodeProcess().

TODO(alexr): Ensure the code working with status is portable by either making WIFEXITED family macros no-op on Windows or converting status to a tuple <termination status, exit code>, see MESOS-7242.

NOTE: Discarding this future has no effect on the subprocess!

Returns
Future from doing a process::reap() of this subprocess. Note that process::reap() never fails or discards this future.

Friends And Related Function Documentation

Try<Subprocess> subprocess ( const std::string &  path,
std::vector< std::string >  argv,
const Subprocess::IO in,
const Subprocess::IO out,
const Subprocess::IO err,
const flags::FlagsBase flags,
const Option< std::map< std::string, std::string >> &  environment,
const Option< lambda::function< pid_t(const lambda::function< int()> &)>> &  clone,
const std::vector< Subprocess::ParentHook > &  parent_hooks,
const std::vector< Subprocess::ChildHook > &  child_hooks 
)
friend

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