Reference Manual

Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

# Inti::G::Spawn Class Reference

A C++ interface for the GLib spawn functions. More...

`#include <inti/glib/spawn.h>`

Inheritance diagram for Inti::G::Spawn:

List of all members.

## Public Types

- typedef Slot0< void > ChildSetupSlot
    Signature of the callback slot to be called after GLib has performed all the setup it plans to perform but before calling exec().

## Public Member Functions

Constructors

- ~Spawn ()
    Destructor.

Methods

- void set_working_directory (const std::string &working_directory)
    Sets the child's current working directory.
- void set_enviroment (std::vector< std::string > &envp)
    Sets the child's enviroment.

## Protected Member Functions

Constructors

- Spawn ()
    Constructs a new Spawn object.

Accessors

- const char * get_working_directory () const
    Returns the current working directory, or null.
- char ** get_argv () const
    Returns a pointer to the argument array to pass to the child, or null.
- char ** get_envp () const
    Returns a pointer to the enviroment array to pass to the child, or null.
- GSpawnFlags get_flags () const
    Returns the flags to pass to the child process spawned.

Methods

- void set_arguments (const std::vector< std::string > &argv, SpawnFlagsField flags)
    Sets the child arguments and spawn flags.
- void set_arguments (const std::string &command_line, G::Error *error)
    Sets the child arguments from the command_line string.

## Detailed Description

A C++ interface for the GLib spawn functions.

Rather than wrap the GLib spawn functions individually Inti wraps these functions into two easy to use classes: SpawnAsync and SpawnSync. SpawnAync executes a child program asynchronously (your program will not block waiting for the child to exit) and SpawnSync executes a child synchronously (your program waits for the child to exit before returning).

Spawn is just a convenient base class that implements the code common to both SpawnAsync and SpawnSync. It derives from StackObject so you can only create SpawnAsync and SpawnSync on the stack. Spawn has only two public methods that can be called: set_working_directory() and set_enviroment(). You call set_working_directory() to set the child's current working directory and you call set_enviroment() to set the child's environment. If you call neither of these methods the child will inherit its parent's working directory and enviroment.

## Member Typedef Documentation

typedef Slot0<void> Inti::G::Spawn::ChildSetupSlot

| Signature of the callback slot to be called after GLib has performed all the setup it plans to perform but before calling exec(). Example: Method signature for ChildSetupSlot.
                 void method();
Obviously, actions taken in this method will only affect the child, not the parent.

## Member Function Documentation

void Inti::G::Spawn::set_arguments | ( | const std::string & | command_line,
|  | G::Error * | error
| ) | `[protected]`

  | Sets the child arguments from the command_line string. Parameters:
  command_line | A command line.
  error | The return location for a G::Error.
This method sets the G_SPAWN_SEARCH_PATH flags and unsets all others.

void Inti::G::Spawn::set_arguments | ( | const std::vector< std::string > & | argv,
|  | SpawnFlagsField | flags
| ) | `[protected]`

  | Sets the child arguments and spawn flags. Parameters:
  argv | A reference to a vector of std::string that holds the argument strings.
  flags | The spawn flags to set.

void Inti::G::Spawn::set_enviroment | ( | std::vector< std::string > & | envp | ) |

  | Sets the child's enviroment. Parameters:
  envp | A reference to a vector of std::string that holds the child's enviroment strings.
Each string in the vector must has the form KEY=VALUE. This will become the child's environment. If not specifically set a child will inherit its parent's enviroment.

void Inti::G::Spawn::set_working_directory | ( | const std::string & | working_directory | ) |

  | Sets the child's current working directory. Parameters:
  working_directory | The working directory to set.
If not specifically set a child will inherit its parent's working directory.

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

- spawn.h

Main Page - Footer